UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:49:13";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:19:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 00:19:13', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE programsettings SET companyname = 'GT4', address = 'المنصورة', specializtion = 'jh', phone = '01002019235', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '471502e62c0be89a8d90663028144a83.jpg', roundnumbers = '0', saveprinting = '1', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-05-02',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE programsettings SET companyname = 'GT4', address = 'المنصورة', specializtion = 'jh', phone = '01002019235', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '471502e62c0be89a8d90663028144a83.jpg', roundnumbers = '0', saveprinting = '1', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-05-02',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:49:16";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:50:08";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:20:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:20:08', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:50:08";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:20:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:20:08', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:55:50";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:25:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 00:25:50', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:55:51";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:55:54";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:25:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:25:54', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 20:55:54";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:25:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:25:55', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:08:30";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:38:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:38:30', '1', 'add', '156.210.104.92', '', '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 ('w04فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = 'w04فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01731',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 = '1731';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1731', '1', '2024-05-02', '1', '0','0173101','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1731', '1', '2', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1731', '1', '2', '0', '1731', 'إضافة منتج', 'productController.php', '0', '2', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1731, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1731, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '520', '520', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج w04فسكوز الكمية 2','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10175', '19', '520', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18944295.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10175', '7', '520', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19702576.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'w04فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01731',type ='0', expireDate = '0' , dailyentryId = '10175',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 = '1731';
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 ('502فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '502فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01732',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 = '1732';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1732', '1', '2024-05-02', '1', '0','0173201','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1732', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1732', '1', '1', '0', '1732', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1732, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1732, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 502فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10176', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18944555.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10176', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19702836.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '502فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01732',type ='0', expireDate = '0' , dailyentryId = '10176',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 = '1732';
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 ('506فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '506فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01733',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 = '1733';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1733', '1', '2024-05-02', '1', '0','0173301','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1733', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1733', '1', '1', '0', '1733', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1733, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1733, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 506فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10177', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18944815.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10177', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19703096.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '506فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01733',type ='0', expireDate = '0' , dailyentryId = '10177',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 = '1733';
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 ('528فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '528فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01734',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 = '1734';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1734', '1', '2024-05-02', '1', '0','0173401','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1734', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1734', '1', '1', '0', '1734', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1734, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1734, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 528فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10178', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18945075.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10178', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19703356.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '528فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01734',type ='0', expireDate = '0' , dailyentryId = '10178',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 = '1734';
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 ('6000فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '6000فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01735',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 = '1735';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1735', '1', '2024-05-02', '1', '0','0173501','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1735', '1', '3', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1735', '1', '3', '0', '1735', 'إضافة منتج', 'productController.php', '0', '3', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1735, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1735, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '780', '780', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 6000فسكوز الكمية 3','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10179', '19', '780', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18945855.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10179', '7', '780', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19704136.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '6000فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01735',type ='0', expireDate = '0' , dailyentryId = '10179',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 = '1735';
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 ('600فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '600فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01736',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 = '1736';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1736', '1', '2024-05-02', '1', '0','0173601','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1736', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1736', '1', '1', '0', '1736', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1736, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1736, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 600فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10180', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18946115.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10180', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19704396.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '600فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01736',type ='0', expireDate = '0' , dailyentryId = '10180',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 = '1736';
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 ('6001فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '6001فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01737',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 = '1737';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1737', '1', '2024-05-02', '1', '0','0173701','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1737', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1737', '1', '1', '0', '1737', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1737, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1737, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 6001فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10181', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18946375.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10181', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19704656.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '6001فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01737',type ='0', expireDate = '0' , dailyentryId = '10181',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 = '1737';
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 ('فسكوز601','','1','260','260', '300','270', '2024-05-02', '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 = 'فسكوز601', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01738',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 = '1738';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1738', '1', '2024-05-02', '1', '0','0173801','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1738', '1', '2', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1738', '1', '2', '0', '1738', 'إضافة منتج', 'productController.php', '0', '2', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1738, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1738, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '520', '520', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج فسكوز601 الكمية 2','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10182', '19', '520', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18946895.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10182', '7', '520', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19705176.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'فسكوز601', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01738',type ='0', expireDate = '0' , dailyentryId = '10182',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 = '1738';
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 ('فسكوز610','','1','260','260', '300','270', '2024-05-02', '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 = 'فسكوز610', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01739',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 = '1739';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1739', '1', '2024-05-02', '1', '0','0173901','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1739', '1', '2', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1739', '1', '2', '0', '1739', 'إضافة منتج', 'productController.php', '0', '2', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1739, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1739, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '520', '520', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج فسكوز610 الكمية 2','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10183', '19', '520', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18947415.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10183', '7', '520', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19705696.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'فسكوز610', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01739',type ='0', expireDate = '0' , dailyentryId = '10183',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 = '1739';
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 ('6010فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',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 = '1740';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1740', '1', '2024-05-02', '1', '0','0174001','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1740', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1740', '1', '1', '0', '1740', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1740, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1740, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 6010فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10184', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18947675.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10184', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19705956.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',type ='0', expireDate = '0' , dailyentryId = '10184',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 = '1740';
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 ('4011فسكوز','','1','260','260', '300','270', '2024-05-02', '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 = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',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 = '1741';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1741', '1', '2024-05-02', '1', '0','0174101','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1741', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '1', '1', '0', '1741', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1741, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1741, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 4011فسكوز الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10185', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18947935.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10185', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19706216.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',type ='0', expireDate = '0' , dailyentryId = '10185',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 = '1741';
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 ('6001','','1','260','260', '300','270', '2024-05-02', '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 = '6001', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01742',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 = '1742';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1742', '1', '2024-05-02', '1', '0','0174201','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1742', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1742', '1', '1', '0', '1742', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1742, 1,'2024-05-02 00:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 1742, edited = 1, sysdate = '2024-05-02 00:38:31', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:38:31','إضافة منتج 6001 الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10186', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18948195.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10186', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19706476.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '6001', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01742',type ='0', expireDate = '0' , dailyentryId = '10186',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 = '1742';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:08:33";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:38:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:38:33', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:09:00";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:39:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:39:00', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:09:00";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:39:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:39:01', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:14:05";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:44:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:44:05', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:14:06";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:44:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:44:06', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:14:14";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:44:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:44:14', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:07";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:07', '1', 'add', '156.210.104.92', '', '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 ('فسكوز40011','','1','260','260', '300','270', '2024-05-02', '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 = 'فسكوز40011', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01743',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 = '1743';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1743', '1', '2024-05-02', '1', '0','0174301','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1743', '1', '01', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1743', '1', '01', '0', '1743', 'إضافة منتج', 'productController.php', '0', '01', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1743, 1,'2024-05-02 00:47:07',1)
                ON DUPLICATE KEY UPDATE productid = 1743, edited = 1, sysdate = '2024-05-02 00:47:07', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:47:07','إضافة منتج فسكوز40011 الكمية 01','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10187', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18948455.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10187', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19706736.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'فسكوز40011', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01743',type ='0', expireDate = '0' , dailyentryId = '10187',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 = '1743';
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 ('فسكوز528','','1','260','260', '300','270', '2024-05-02', '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 = 'فسكوز528', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01744',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 = '1744';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1744', '1', '2024-05-02', '1', '0','0174401','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1744', '1', '1', '1', '2024-05-02');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1744', '1', '1', '0', '1744', 'إضافة منتج', 'productController.php', '0', '1', '1', '2024-05-02','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1744, 1,'2024-05-02 00:47:07',1)
                ON DUPLICATE KEY UPDATE productid = 1744, edited = 1, sysdate = '2024-05-02 00:47:07', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '260', '260', '2024-05-02', '1', '0', '0', '2024-05-02 00:47:07','إضافة منتج فسكوز528 الكمية 1','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10188', '19', '260', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18948715.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10188', '7', '260', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19706996.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'فسكوز528', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01744',type ='0', expireDate = '0' , dailyentryId = '10188',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 = '1744';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:09";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:09', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:16";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:16', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:19";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:47:19', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:24";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:24', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:27";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:27', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:31";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 00:47:31', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:31";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:34";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 00:47:34', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:35";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:37";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:37', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:41";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:41', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:43";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:47:43', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:47";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:47', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:50";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:50', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:55";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-02 00:47:55', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:59";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:47:59', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:17:59";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:47:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:47:59', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:21:15";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:51:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:51:15', '1', 'add', '156.210.104.92', '', '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(1980,1,7,1731,2,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 00:51:15',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6244';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1731, 0, 0
                    , 260.00, -2, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-05-02*260.00," WHERE transferproductid = 8491;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1731', '1', '2', '1', '8491', 'تحويل منتجات من المخزن', 'storemovementController.php', '2.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1731', '7', '2', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1731, 0, 0
                    , 260.00, 2, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1731', '7', '2', '0', '8491', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '2', '1', '2024-05-02','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', '1732', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:15',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6245';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1732, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8492;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1732', '1', '1', '1', '8492', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1732', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1732, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1732', '7', '1', '0', '8492', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1733', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:15',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6246';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1733, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8493;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1733', '1', '1', '1', '8493', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1733', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1733, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1733', '7', '1', '0', '8493', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1744', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:15',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6257';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1744, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8494;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1744', '1', '1', '1', '8494', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1744', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1744, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1744', '7', '1', '0', '8494', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1735', '3', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:15',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6248';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1735, 0, 0
                    , 260.00, -3, 0, 0, 1, '2024-05-02 00:51:15')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:15' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2024-05-02*260.00," WHERE transferproductid = 8495;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1735', '1', '3', '1', '8495', 'تحويل منتجات من المخزن', 'storemovementController.php', '3.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1735', '7', '3', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1735, 0, 0
                    , 260.00, 3, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1735', '7', '3', '0', '8495', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '3', '1', '2024-05-02','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', '1739', '2', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6252';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1739, 0, 0
                    , 260.00, -2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-05-02*260.00," WHERE transferproductid = 8496;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1739', '1', '2', '1', '8496', 'تحويل منتجات من المخزن', 'storemovementController.php', '2.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1739', '7', '2', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1739, 0, 0
                    , 260.00, 2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1739', '7', '2', '0', '8496', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '2', '1', '2024-05-02','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', '1736', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6249';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1736, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8497;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1736', '1', '1', '1', '8497', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1736', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1736, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1736', '7', '1', '0', '8497', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1737', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6250';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1737, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8498;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1737', '1', '1', '1', '8498', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1737', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1737, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1737', '7', '1', '0', '8498', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1738', '2', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6251';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1738, 0, 0
                    , 260.00, -2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-05-02*260.00," WHERE transferproductid = 8499;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1738', '1', '2', '1', '8499', 'تحويل منتجات من المخزن', 'storemovementController.php', '2.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1738', '7', '2', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1738, 0, 0
                    , 260.00, 2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1738', '7', '2', '0', '8499', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '2', '1', '2024-05-02','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', '1740', '1', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6253';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1740, 0, 0
                    , 260.00, -1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*260.00," WHERE transferproductid = 8500;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1740', '1', '1', '1', '8500', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1740', '7', '1', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1740, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1740', '7', '1', '0', '8500', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-05-02','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', '1741', '2', '2024-05-02', '1', '0','1980',null,null,'2024-05-02 00:51:16',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6254';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1741, 0, 0
                    , 260.00, -2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-05-02*260.00," WHERE transferproductid = 8501;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '1', '2', '1', '8501', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '-1', '1', '2024-05-02','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1741', '7', '2', '1', '2024-05-02');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1741, 0, 0
                    , 260.00, 2, 0, 0, 1, '2024-05-02 00:51:16')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 00:51:16' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '7', '2', '0', '8501', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '2', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:21:16";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 00:51:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 00:51:16', '1', 'editshow', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:34:02";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:04:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 01:04:02', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:34:03";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:34:34";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:04:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-05-02 01:04:34', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:34:35";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:04:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-05-02 01:04:35', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:40:24";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:10:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:10:24', '1', '', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:43:33";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:13:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:13:33', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '19.00', '20', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:43:35";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:13:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:13:35', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:44:10";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:14:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:14:10', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6143';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1695', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '38.00', '40', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:44:10";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:14:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:14:10', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6143';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1695', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '38.00', '40', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:44:12";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:14:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:14:12', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:44:46";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:14:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:14:46', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6128';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1688', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '1.00', '5', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:44:48";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:14:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:14:48', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:46:31";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:16:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:16:31', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6100';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1679', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '6.00', '8', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:46:33";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:16:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:16:33', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:47:27";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:17:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:17:27', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6084';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1674', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '8.00', '12', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:47:29";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:17:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:17:29', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:48:03";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:18:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:18:03', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6057';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1662', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '11', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:48:05";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:18:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:18:06', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:48:57";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:18:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:18:57', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6055';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '15.00', '13', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:48:59";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:18:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:18:59', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:49:32";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:19:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:19:32', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6036';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1659', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '4.00', '3', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:49:34";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:19:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:19:35', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:50:19";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:20:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:20:19', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5953';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1564', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '9.00', '11', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:50:21";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:20:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:20:21', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:53:02";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:23:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:23:02', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '5', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '3.00', '11', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:53:04";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:23:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:23:05', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:53:30";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:23:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:23:30', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5914';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1624', '5', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '15.00', '20', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:53:32";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:23:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:23:32', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:54:38";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:24:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:24:38', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5812';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1590', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '3.00', '7', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:54:40";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:24:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:24:40', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:55:58";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:25:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:25:58', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5721';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1552', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '10', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:56:00";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:26:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:26:00', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:56:24";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:26:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:26:25', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5717';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1550', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '13.00', '12', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:56:25";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:26:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:26:25', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5717';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1550', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '13.00', '12', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:56:27";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:26:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:26:27', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:56:58";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:26:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:26:58', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5714';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1537', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '6', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:57:00";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:27:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:27:00', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:57:26";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:27:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:27:26', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5711';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '13.00', '14', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:57:26";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:27:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:27:26', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5711';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '13.00', '14', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:57:28";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:27:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:27:29', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:57:58";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:27:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:27:58', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5710';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1587', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '16.00', '14', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:58:00";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:28:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:28:01', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:58:23";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:28:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:28:23', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5708';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1533', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '9.00', '8', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:58:25";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:28:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:28:25', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:58:49";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:28:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:28:49', '1', 'add', '156.210.104.92', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5703';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1524', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '10.00', '8', '1', '2024-05-02','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-01 21:58:51";
UPDATE user SET loginip = "156.210.104.92", lastactivetime = "2024-05-02 01:28:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-02 01:28:51', '1', 'show', '156.210.104.92', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 05:27:38";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 05:27:44";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 08:57:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 08: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-05-02 05: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-05-02 05:27:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 08:57:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 08:57:46', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 05:27:56";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 08:57:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 08:57:56', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 06:11:11";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 09:41:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 09:41:11', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 06:11:15";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 09:41:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 09:41:15', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 06:41:50";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 06:41:56";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:11:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 10:11:56', '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-05-02 06:41:56";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 06:41:59";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:12:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 10:12:00', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:12:12";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:12:18";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:42:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 10:42: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-05-02 07:12: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-05-02 07:12:22";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:42:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 10:42:22', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:15:27";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:45:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 10:45:27', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:16:07";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:46:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 10:46:07', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:16:10";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:46:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 10:46:10', '4', 'editprint', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 07:16:21";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 10:46:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 10:46:21', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 10:38:38";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:08:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 14:08:38', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 10:38: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-05-02 10:50:38";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:20:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:20:38', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 10:50:39";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:20:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:20:39', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:03:07";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:33:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:33:07', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:04:47";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:34:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 14:34:47', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:07:23";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:37:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 14:37:23', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:07:23";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:37:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 14:37:23', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:07:27";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:37:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 14:37:27', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:07:27";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:37:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 14:37:27', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:07:46";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:08:06";
UPDATE user SET loginip = "197.192.199.72", lastactivetime = "2024-05-02 14:38:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 14:38:06', '7', '', '197.192.199.72', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:08:06";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:08:13";
UPDATE user SET loginip = "197.192.199.72", lastactivetime = "2024-05-02 14:38:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:38:13', '7', 'addsellBill', '197.192.199.72', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:11:50";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:41:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:41:50', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:11:55";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:41:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:41:55', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:24";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:24', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:32";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:32', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:33";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:33', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:35";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:35', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:37";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:37', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:41";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:41', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:43";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:43', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:45";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:45', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:46', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:48";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:48', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:12:49";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:42:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:42:49', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:12";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:44:13", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:44:13', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:20";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:20', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:21";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:22', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:23";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:23', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:24";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:24', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:26', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:27";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:44:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:44:27', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:14:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:44:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 14:44:45', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:03', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:04";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:04", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 14:45:04', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:05";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:05', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:06";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:06', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:07";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 14:45:08', '4', 'editprint', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:08";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:08', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:09";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:09', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:10";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:10', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:24";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:45:24', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:28";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 14:45:28', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:37";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 14:45:37', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:38";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 14:45:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 14:45:39', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:51";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:51', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:52";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:53', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:54";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:54', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:55";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:55', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:56";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:57', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:15:58";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:45:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:45:58', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:00";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:00', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:01";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:01', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:03";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:04', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:06";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:06', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:40";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:41', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:42";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:42', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:43";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:43', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:45";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:45', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:48";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:48', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:50";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:50', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:52";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:52', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:54";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:54', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:16:56";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:46:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:46:56', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:00";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:00', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:04";
UPDATE user SET loginip = "197.192.199.72", lastactivetime = "2024-05-02 14:47:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:47:04', '7', 'addsellBill', '197.192.199.72', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:22";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:23', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:24";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:24', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:26', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:27";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:28', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:29";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:29', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:31";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:31', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:32";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:32', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:34";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:35', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:37";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:38', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:40";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:40', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:17:41";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:47:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:47:42', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:30";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:30', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:31";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:31', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:33";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:33', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:34";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:35', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:36";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:37', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:37";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:37', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:38";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:38', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:40";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:40', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:42";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:42', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:18:43";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:48:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:48:43', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:28:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:58:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:58:26', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:28:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:58:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 14:58:27', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:28:33";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:58:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:58:33', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:28:34";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 14:58:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 14:58:35', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:46:17";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:16:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:16:17', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:46:21";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:16:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:16:25', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:33";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:33', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:50";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:50', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:51";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:51', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:53";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:55', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:55";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:55', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:56";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:56', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:57";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:57', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:58";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:58', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:47:59";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:17:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:17:59', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:48:00";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:18:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:18:01', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:48:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:18:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:18:02', '1', 'editorder', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:49:04";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:19:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 15:19:04', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:50:31";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:20:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:20:31', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:53:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:23:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:23:26', '1', 'add', '156.210.126.78', '', '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(1981,7,1,1546,18,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 15:23:27',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5846';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1546, 0, 0
                    , 340.00, 3, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-3, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 7, 1546, 0, 0
                    , 340.00, 15, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-15, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2024-02-25*340.00,15*2024-02-29*340.00," WHERE transferproductid = 8502;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '7', '18', '1', '8502', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5583';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1546, 0, 0
                    , 340.00, 3, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 1, 1546, 0, 0
                    , 340.00, 15, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '1', '18', '0', '8502', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '18', '1', '2024-05-02','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', '1567', '10', '2024-05-02', '1', '0','1981',null,null,'2024-05-02 15:23:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5760';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1567, 0, 0
                    , 300.00, 10, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-02-25*300.00," WHERE transferproductid = 8503;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1567', '7', '10', '1', '8503', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5604';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1567, 0, 0
                    , 300.00, 10, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1567', '1', '10', '0', '8503', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '10', '1', '2024-05-02','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', '22', '2024-05-02', '1', '0','1981',null,null,'2024-05-02 15:23:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5833';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 1606, 0, 0
                    , 410.00, -22, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyprice = 410.00,
                        buyQuantity =buyQuantity+-22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-05-02*410.00," WHERE transferproductid = 8504;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1606', '7', '22', '1', '8504', 'تحويل منتجات من المخزن', 'storemovementController.php', '22.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5825';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1606, 0, 0
                    , 410.00, 22, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1606', '1', '22', '0', '8504', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '13.00', '35', '1', '2024-05-02','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', '1571', '22', '2024-05-02', '1', '0','1981',null,null,'2024-05-02 15:23:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5752';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1571, 0, 0
                    , 400.00, 22, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-22, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-02-25*400.00," WHERE transferproductid = 8505;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1571', '7', '22', '1', '8505', 'تحويل منتجات من المخزن', 'storemovementController.php', '22.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5608';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1571, 0, 0
                    , 400.00, 22, 0, 0, 1, '2024-05-02 15:23:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:23:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1571', '1', '22', '0', '8505', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '22', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:53:27";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:23:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:23:27', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:53:34";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:23:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:23:34', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:55:41";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:25:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:25:41', '1', 'add', '156.210.126.78', '', '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(1982,1,5,1567,10,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 15:25:41',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5604';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1567, 0, 0
                    , 300.00, -10, 0, 0, 1, '2024-05-02 15:25:41')
                ON DUPLICATE KEY UPDATE buyprice = 300.00,
                        buyQuantity =buyQuantity+-10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:25:41' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-05-02*300.00," WHERE transferproductid = 8506;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1567', '1', '10', '1', '8506', 'تحويل منتجات من المخزن', 'storemovementController.php', '10.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5677';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1567, 0, 0
                    , 300.00, 10, 0, 0, 1, '2024-05-02 15:25:41')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:25:41' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1567', '5', '10', '0', '8506', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '12', '1', '2024-05-02','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', '1546', '18', '2024-05-02', '1', '0','1982',null,null,'2024-05-02 15:25:41',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5583';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1546, 0, 0
                    , 340.00, -18, 0, 0, 1, '2024-05-02 15:25:41')
                ON DUPLICATE KEY UPDATE buyprice = 340.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:25:41' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-05-02*340.00," WHERE transferproductid = 8507;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '1', '18', '1', '8507', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5675';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1546, 0, 0
                    , 340.00, 18, 0, 0, 1, '2024-05-02 15:25:41')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:25:41' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '5', '18', '0', '8507', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '3.00', '21', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 11:55:41";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:25:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:25:41', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:02:18";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:32:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:32:18', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:02:18";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:32:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:32:18', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:02:45";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:32:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:32:45', '1', 'add', '156.210.126.78', '', '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(1983,6,5,1621,7,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 15:32:45',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5921';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-25', 6, 1621, 0, 0
                    , 475.00, 7, 0, 0, 1, '2024-05-02 15:32:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-7, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:32:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "7*2024-03-25*475.00," WHERE transferproductid = 8508;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '6', '7', '1', '8508', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '4', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5920';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-25', 5, 1621, 0, 0
                    , 475.00, 7, 0, 0, 1, '2024-05-02 15:32:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+7, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 15:32:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '5', '7', '0', '8508', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '11.00', '18', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:02:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:32:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 15:32:46', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:08:30";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:38:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 15:38:30', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:10:44";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:40:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 15:40:44', '4', 'add', '197.35.233.37', '', '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 =24967
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(410,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '2260' , clientdate = '2024-05-02 15:40:44', userid = '4' WHERE clientid = '410';
UPDATE client SET  inUse = 0 where clientid = 410;
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 ('410','3760.00','1500','1','ايصال تحصيل (( قبض من عميل ))','24967', '2260', '2024-05-02 14:37:28', '4', 'clientPayedDeptController.php', '   ', '1500', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '23355',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('21855.00','1500', '0', '7', 'ايصال تحصيل (( قبض من عميل ))', '24967', '23355', '2024-05-02 15:40:44', '4',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1500', '1500', '2024-05-02', '4', '0', '0', '2024-05-02 15:40:44','اضافة ايصال سداد للعميل عمي عدلي عدلي','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10189', '141', '1500', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2018892', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10189', '480', '1500', '','0');
UPDATE accountstree SET name = 'عمي عدلي عدلي', customName = 'عمي عدلي عدلي', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '4', mydate = '2024-04-13', itemtype2 = '1', theValue = '-8500', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '480';
UPDATE clientdebtchange SET clientid = '410', clientdebtchangebefore = '3760.00', clientdebtchangeamount = '1500.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '24967', clientdebtchangeafter = '2260.00', clientdebtchangedate = '2024-05-02 14:37:28', userid = '4', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1500.00',discount='', reciptid=null, dailyentryid = '10189',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '24967';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:10:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:40:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 15:40:45', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:10:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:40:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-02 15:40:46', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:10:48";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:40:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 15:40:48', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:10:59";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:40:59", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 15:40:59', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:12:56";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:42:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 15:42:56', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:13:12";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:43:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 15:43:12', '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', 'للشيخ وليد امبارح بعتهم مع جمال بوظه', '', '21855', '2024-05-02', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '1500',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('23355.00','21855', '1', '7', 'إضافة مصروف', '4973', '1500', '2024-05-02 15:43:12', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '21855', '21855', '2024-05-02', '4', '0', '0', '2024-05-02 15:43:12','اضافة اسم مصروف( للشيخ وليد امبارح بعتهم مع جمال بوظه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10190', '160', '21855', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4472653', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10190', '141', '21855', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2040747', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'للشيخ وليد امبارح بعتهم مع جمال بوظه', expensesdetails = '', expensesValue = '21855.00', expensesdate = '2024-05-02', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10190', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4973';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:13:12";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:43:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 15:43:12', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:13:14";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:43:14", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 15:43:14', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:13:15";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 15:43:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 15:43:16', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:24:14";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 15:54:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 15:54:14', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:33:25";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:03:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:03:25', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:36:39";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:06:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 16:06:39', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:38:50";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:08:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:08:50', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:43:13";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 16:13:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:13:14', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:47:23";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:17:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 16:17:23', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:47:29";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:17:29", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:17:29', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:51:32";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:21:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:21:33', '4', 'addAndRetuen', '197.35.233.37', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066339269b9495
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-05-02 16:17:29', '066339269b9495', '1', '0.00', '0', '0', '1', '800', '800', '800', '0', '7', '2024-05-02 16:21:33', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','800','0','','0','0','800','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','اضافة فاتورة مبيعات','16852', '0', '2024-05-02 16:21:33', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18343;
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','01728', '16852', '1', '1728', '1', '360.00', '360', '0', '', '2', '2024-05-02 16:21:33', '1728', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','18343-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 50069;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1728, '2024-05-02', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-05-02', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '24', userid = '4', storedetaildate = '2024-05-02 16:21:33' WHERE storedetailid = '6240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1728', '7', '1', '1', '16852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25.00', '24', '4', '2024-05-02 16:21:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17339;
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','01599', '16852', '1', '1599', '1', '440.00', '440', '0', '', '2', '2024-05-02 16:21:33', '1599', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17339-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 50070;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1599, '2024-05-02', 440, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, 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 (7, '2024-05-02', 440, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, 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 = '5', userid = '4', storedetaildate = '2024-05-02 16:21:33' WHERE storedetailid = '5829';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1599', '7', '1', '1', '16852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '4', '2024-05-02 16:21:33','0','0');
UPDATE save SET  savecurrentvalue = '2300',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1500.00','800', '0', '7', 'اضافة فاتورة مبيعات', '16852', '2300', '2024-05-02 16:21:33', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-02', 800, 760, 760
                    , 760, 760, 760, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-05-02', 800, 760, 760
                    , 760, 760, 760, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 800, 760, 760
                    , 760, 760, 760, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+760
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+760
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+760
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+760
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+760
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066339269b9495 and sellbillId = 16852 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:58:47";
UPDATE user SET loginip = "197.63.252.236", lastactivetime = "2024-05-02 16:28:47", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:28:47', '8', 'addsellBill', '197.63.252.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 12:58:47";
UPDATE user SET loginip = "197.63.252.236", lastactivetime = "2024-05-02 16:28:47", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 16:28:47', '8', 'addsellBill', '197.63.252.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:03:43";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:33:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 16:33:43', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:05:39";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:35:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:35:39', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:22";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:22', '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', 'النسبه اسبوع', '', '350', '2024-05-02', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '1950',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2300.00','350', '1', '7', 'إضافة مصروف', '4974', '1950', '2024-05-02 16:36:22', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '350', '350', '2024-05-02', '4', '0', '0', '2024-05-02 16:36:22','اضافة اسم مصروف( النسبه اسبوع )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10191', '160', '350', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4473003', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10191', '141', '350', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2041097', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'النسبه اسبوع', expensesdetails = '', expensesValue = '350.00', expensesdate = '2024-05-02', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10191', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4974';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:22";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:22', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:24";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:24', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:25";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:26', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:58";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:58', '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', 'قبض احمد نبروة بالمصروف', '', '520', '2024-05-02', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '1430',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1950.00','520', '1', '7', 'إضافة مصروف', '4975', '1430', '2024-05-02 16:36:58', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '520', '520', '2024-05-02', '4', '0', '0', '2024-05-02 16:36:58','اضافة اسم مصروف( قبض احمد نبروة بالمصروف )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10192', '160', '520', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4473523', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10192', '141', '520', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2041617', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'قبض احمد نبروة بالمصروف', expensesdetails = '', expensesValue = '520.00', expensesdate = '2024-05-02', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10192', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4975';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:06:59";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:36:59", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:36:59', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:07:00";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:37:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 16:37:00', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 13:07:38";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-05-02 16:37:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 16:37:38', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:18:33";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:18:33";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:18:53";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 17:48:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 17:48:53', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:18:54";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:19:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 17:49:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 17:49:03', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:19:03";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 17:49:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 17:49:03', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:41:45";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:11:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:11:45', '1', 'add', '156.210.126.78', '', '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(1984,5,1,1565,15,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 18:11:46',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5679';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1565, 0, 0
                    , 300.00, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1565, 0, 0
                    , 300.00, -6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 300.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2024-02-25*300.00,6*2024-05-02*300.00," WHERE transferproductid = 8509;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1565', '5', '15', '1', '8509', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '-2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '42', userid = '1', storedetaildate = '2024-05-02' 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, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1565, 0, 0
                    , 300.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1565', '1', '15', '0', '8509', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '27.00', '42', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1539', '13', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5716';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1539, 0, 0
                    , 430.00, 11, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-11, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1539, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "11*2024-02-25*430.00,2*2024-05-02*430.00," WHERE transferproductid = 8510;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1539', '5', '13', '1', '8510', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5576';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1539, 0, 0
                    , 430.00, 11, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+11, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1539, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1539', '1', '13', '0', '8510', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1535', '5', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5712';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1535, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1535, 0, 0
                    , 430.00, -4, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-02-25*430.00,4*2024-05-02*430.00," WHERE transferproductid = 8511;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1535', '5', '5', '1', '8511', 'تحويل منتجات من المخزن', 'storemovementController.php', '5.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5572';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1535, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1535, 0, 0
                    , 430.00, 4, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1535', '1', '5', '0', '8511', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '5', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1564', '11', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5953';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-19', 5, 1564, 0, 0
                    , 350.00, 5, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-5, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1564, 0, 0
                    , 350.00, -6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "5*2024-03-19*350.00,6*2024-05-02*350.00," WHERE transferproductid = 8512;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1564', '5', '11', '1', '8512', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5601';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-19', 1, 1564, 0, 0
                    , 350.00, 5, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1564, 0, 0
                    , 350.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1564', '1', '11', '0', '8512', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '11', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1559', '4', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5699';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1559, 0, 0
                    , 360.00, -4, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 360.00,
                        buyQuantity =buyQuantity+-4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "4*2024-05-02*360.00," WHERE transferproductid = 8513;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1559', '5', '4', '1', '8513', 'تحويل منتجات من المخزن', 'storemovementController.php', '3.00', '-1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5596';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1559, 0, 0
                    , 360.00, 4, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1559', '1', '4', '0', '8513', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '4', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1562', '11', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5700';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1562, 0, 0
                    , 370.00, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1562, 0, 0
                    , 370.00, -3, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 370.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-02-25*370.00,3*2024-05-02*370.00," WHERE transferproductid = 8514;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1562', '5', '11', '1', '8514', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5599';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1562, 0, 0
                    , 370.00, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1562, 0, 0
                    , 370.00, 3, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1562', '1', '11', '0', '8514', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '11', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1633', '15', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5929';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-12', 5, 1633, 0, 0
                    , 210.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-13, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1633, 0, 0
                    , 210.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2024-03-12*210.00,2*2024-05-02*210.00," WHERE transferproductid = 8515;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1633', '5', '15', '1', '8515', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '-2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5928';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-12', 1, 1633, 0, 0
                    , 210.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1633, 0, 0
                    , 210.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1633', '1', '15', '0', '8515', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '15', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1519', '10', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5709';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1519, 0, 0
                    , 210.00, 10, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-02-25*210.00," WHERE transferproductid = 8516;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1519', '5', '10', '1', '8516', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5556';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1519, 0, 0
                    , 210.00, 10, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1519', '1', '10', '0', '8516', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '10', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1676', '8', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6098';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 5, 1676, 0, 0
                    , 425.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-6, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1676, 0, 0
                    , 425.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 425.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-03-30*425.00,2*2024-05-02*425.00," WHERE transferproductid = 8517;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1676', '5', '8', '1', '8517', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6087';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 1, 1676, 0, 0
                    , 425.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1676, 0, 0
                    , 425.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1676', '1', '8', '0', '8517', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '8', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1591', '24', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5810';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 5, 1591, 0, 0
                    , 390.00, 22, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-22, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1591, 0, 0
                    , 390.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 390.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-02-28*390.00,2*2024-05-02*390.00," WHERE transferproductid = 8518;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1591', '5', '24', '1', '8518', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5800';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1591, 0, 0
                    , 390.00, 22, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1591, 0, 0
                    , 390.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1591', '1', '24', '0', '8518', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '24', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1590', '3', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5812';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 5, 1590, 0, 0
                    , 385.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1590, 0, 0
                    , 385.00, -1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 385.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-02-28*385.00,1*2024-05-02*385.00," WHERE transferproductid = 8519;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1590', '5', '3', '1', '8519', 'تحويل منتجات من المخزن', 'storemovementController.php', '7.00', '4', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5799';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1590, 0, 0
                    , 385.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1590, 0, 0
                    , 385.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1590', '1', '3', '0', '8519', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '3', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1589', '23', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5811';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 5, 1589, 0, 0
                    , 370.00, 23, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-23, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2024-02-28*370.00," WHERE transferproductid = 8520;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1589', '5', '23', '1', '8520', 'تحويل منتجات من المخزن', 'storemovementController.php', '23.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5798';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1589, 0, 0
                    , 370.00, 23, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1589', '1', '23', '0', '8520', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '23', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1556', '14', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5682';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1556, 0, 0
                    , 390.00, 14, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-14, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-02-25*390.00," WHERE transferproductid = 8521;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1556', '5', '14', '1', '8521', 'تحويل منتجات من المخزن', 'storemovementController.php', '14.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5593';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1556, 0, 0
                    , 390.00, 14, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1556', '1', '14', '0', '8521', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '14', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1557', '8', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5683';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1557, 0, 0
                    , 440.00, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-02-25*440.00," WHERE transferproductid = 8522;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1557', '5', '8', '1', '8522', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5594';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1557, 0, 0
                    , 440.00, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1557', '1', '8', '0', '8522', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '8', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1555', '9', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5681';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1555, 0, 0
                    , 425.00, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2024-02-25*425.00," WHERE transferproductid = 8523;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1555', '5', '9', '1', '8523', 'تحويل منتجات من المخزن', 'storemovementController.php', '9.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5592';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1555, 0, 0
                    , 425.00, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1555', '1', '9', '0', '8523', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '9', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1558', '1', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5684';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1558, 0, 0
                    , 430.00, -1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-05-02*430.00," WHERE transferproductid = 8524;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1558', '5', '1', '1', '8524', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5595';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1558, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1558', '1', '1', '0', '8524', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '1', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1554', '3', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5680';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1554, 0, 0
                    , 425.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1554, 0, 0
                    , 425.00, -1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 425.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-02-25*425.00,1*2024-05-02*425.00," WHERE transferproductid = 8525;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1554', '5', '3', '1', '8525', 'تحويل منتجات من المخزن', 'storemovementController.php', '3.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5591';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1554, 0, 0
                    , 425.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1554, 0, 0
                    , 425.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1554', '1', '3', '0', '8525', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '3', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1678', '10', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6103';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 5, 1678, 0, 0
                    , 390.00, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1678, 0, 0
                    , 390.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 390.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-03-30*390.00,2*2024-05-02*390.00," WHERE transferproductid = 8526;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '5', '10', '1', '8526', 'تحويل منتجات من المخزن', 'storemovementController.php', '10.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '39', userid = '1', storedetaildate = '2024-05-02' 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, 8, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1678, 0, 0
                    , 390.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '1', '10', '0', '8526', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '29.00', '39', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1545', '10', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5674';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1545, 0, 0
                    , 280.00, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1545, 0, 0
                    , 280.00, -1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 280.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2024-02-25*280.00,1*2024-05-02*280.00," WHERE transferproductid = 8527;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1545', '5', '10', '1', '8527', 'تحويل منتجات من المخزن', 'storemovementController.php', '10.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5582';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1545, 0, 0
                    , 280.00, 9, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1545, 0, 0
                    , 280.00, 1, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1545', '1', '10', '0', '8527', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '28', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1544', '13', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5672';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1544, 0, 0
                    , 280.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-13, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2024-02-25*280.00," WHERE transferproductid = 8528;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1544', '5', '13', '1', '8528', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5581';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1544, 0, 0
                    , 280.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1544', '1', '13', '0', '8528', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '31', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1534', '13', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5711';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1534, 0, 0
                    , 430.00, 11, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-11, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1534, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "11*2024-02-25*430.00,2*2024-05-02*430.00," WHERE transferproductid = 8529;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '5', '13', '1', '8529', 'تحويل منتجات من المخزن', 'storemovementController.php', '14.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5571';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1534, 0, 0
                    , 430.00, 11, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+11, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1534, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '1', '13', '0', '8529', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1536', '13', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5713';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1536, 0, 0
                    , 430.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-13, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2024-02-25*430.00," WHERE transferproductid = 8530;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1536', '5', '13', '1', '8530', 'تحويل منتجات من المخزن', 'storemovementController.php', '14.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5573';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1536, 0, 0
                    , 430.00, 13, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1536', '1', '13', '0', '8530', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1538', '12', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5715';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1538, 0, 0
                    , 430.00, 10, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1538, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-02-25*430.00,2*2024-05-02*430.00," WHERE transferproductid = 8531;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1538', '5', '12', '1', '8531', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5575';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1538, 0, 0
                    , 430.00, 10, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1538, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1538', '1', '12', '0', '8531', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1537', '8', '2024-05-02', '1', '0','1984',null,null,'2024-05-02 18:11:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5714';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1537, 0, 0
                    , 430.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-6, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 5, 1537, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-02-25*430.00,2*2024-05-02*430.00," WHERE transferproductid = 8532;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1537', '5', '8', '1', '8532', 'تحويل منتجات من المخزن', 'storemovementController.php', '6.00', '-2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5574';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1537, 0, 0
                    , 430.00, 6, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1537, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:11:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:11:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1537', '1', '8', '0', '8532', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '8', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:41:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:11:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:11:47', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:51:09";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:21:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:21:09', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:52:41";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:22:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:22:41', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:56:57";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:57:02";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:57:07";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:57:44";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 18:27:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 18:27:44', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:57: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 userid = 7;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:59:03";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 18:29:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 18:29:03', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:59:03";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 14:59:20";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 18:29:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:29:20', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:09:01";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:39:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-02 18:39:01', '1', '', '156.210.126.78', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:09:50";
UPDATE user SET loginip = "197.32.254.255", lastactivetime = "2024-05-02 18:39:50", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 18:39:50', '3', '', '197.32.254.255', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:09:51";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:10:13";
UPDATE user SET loginip = "197.32.254.255", lastactivetime = "2024-05-02 18:40:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:40:13', '3', 'addsellBill', '197.32.254.255', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:10:17";
UPDATE user SET loginip = "197.32.254.255", lastactivetime = "2024-05-02 18:40:17", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:40:17', '3', 'addsellBill', '197.32.254.255', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:10:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:40:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-02 18:40:46', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:10:54";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:40:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-02 18:40:54', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:11:00";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:41:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 18:41:00', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:11:08";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:41:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 18:41:08', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:11:26";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:41:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 18:41:26', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:11:53";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:41:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:41:53', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:03";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 18:43:03', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:05";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-02 18:43:05', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:07";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-02 18:43:07', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:08";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:43:08', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:10";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:43:10', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:12";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:43:12', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:17";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 18:43:17', '1', 'addsellBill', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:21";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:43:21', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:43:46', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:13:47";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:43:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:43:47', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:24:17";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:54:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:54:17', '1', 'add', '156.210.126.78', '', '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(1985,6,1,1543,13,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 18:54:17',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5793';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-26', 6, 1543, 0, 0
                    , 240.00, 13, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-13, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2024-02-26*240.00," WHERE transferproductid = 8533;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1543', '6', '13', '1', '8533', 'تحويل منتجات من المخزن', 'storemovementController.php', '19.00', '6', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5580';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-26', 1, 1543, 0, 0
                    , 240.00, 13, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1543', '1', '13', '0', '8533', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1678', '18', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6097';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 6, 1678, 0, 0
                    , 390.00, 18, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-03-30*390.00," WHERE transferproductid = 8534;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '6', '18', '1', '8534', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '57', userid = '1', storedetaildate = '2024-05-02' 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, 18, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '1', '18', '0', '8534', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '39.00', '57', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1540', '14', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5662';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1540, 0, 0
                    , 280.00, 14, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-14, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-02-25*280.00," WHERE transferproductid = 8535;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1540', '6', '14', '1', '8535', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5577';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1540, 0, 0
                    , 280.00, 14, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1540', '1', '14', '0', '8535', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '32', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1632', '12', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5927';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-12', 6, 1632, 0, 0
                    , 250.00, 12, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-03-12*250.00," WHERE transferproductid = 8536;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1632', '6', '12', '1', '8536', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5923';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-12', 1, 1632, 0, 0
                    , 250.00, 12, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1632', '1', '12', '0', '8536', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1591', '32', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5807';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 6, 1591, 0, 0
                    , 390.00, 32, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-32, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2024-02-28*390.00," WHERE transferproductid = 8537;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1591', '6', '32', '1', '8537', 'تحويل منتجات من المخزن', 'storemovementController.php', '32.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '56', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5800';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1591, 0, 0
                    , 390.00, 32, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1591', '1', '32', '0', '8537', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '24.00', '56', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1534', '17', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5656';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1534, 0, 0
                    , 430.00, 16, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-16, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 6, 1534, 0, 0
                    , 430.00, -1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2024-02-25*430.00,1*2024-05-02*430.00," WHERE transferproductid = 8538;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '6', '17', '1', '8538', 'تحويل منتجات من المخزن', 'storemovementController.php', '16.00', '-1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5571';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1534, 0, 0
                    , 430.00, 16, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1534, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1534', '1', '17', '0', '8538', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '13.00', '30', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1535', '2', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5655';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1535, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-02-25*430.00," WHERE transferproductid = 8539;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1535', '6', '2', '1', '8539', 'تحويل منتجات من المخزن', 'storemovementController.php', '3.00', '1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5572';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1535, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1535', '1', '2', '0', '8539', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '5.00', '7', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1539', '16', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5651';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1539, 0, 0
                    , 430.00, 16, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-16, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2024-02-25*430.00," WHERE transferproductid = 8540;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1539', '6', '16', '1', '8540', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5576';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1539, 0, 0
                    , 430.00, 16, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1539', '1', '16', '0', '8540', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '13.00', '29', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1536', '12', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5654';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1536, 0, 0
                    , 430.00, 12, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-02-25*430.00," WHERE transferproductid = 8541;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1536', '6', '12', '1', '8541', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '25', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5573';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1536, 0, 0
                    , 430.00, 12, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1536', '1', '12', '0', '8541', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '13.00', '25', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1589', '27', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5808';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 6, 1589, 0, 0
                    , 370.00, 26, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-26, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 6, 1589, 0, 0
                    , 370.00, -1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyprice = 370.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2024-02-28*370.00,1*2024-05-02*370.00," WHERE transferproductid = 8542;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1589', '6', '27', '1', '8542', 'تحويل منتجات من المخزن', 'storemovementController.php', '27.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '50', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5798';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1589, 0, 0
                    , 370.00, 26, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1589, 0, 0
                    , 370.00, 1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1589', '1', '27', '0', '8542', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '23.00', '50', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1554', '12', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-6', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5667';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1554, 0, 0
                    , 425.00, 6, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-6, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 6, 1554, 0, 0
                    , 425.00, -6, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyprice = 425.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-02-25*425.00,6*2024-05-02*425.00," WHERE transferproductid = 8543;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1554', '6', '12', '1', '8543', 'تحويل منتجات من المخزن', 'storemovementController.php', '6.00', '-6', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5591';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1554, 0, 0
                    , 425.00, 6, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1554, 0, 0
                    , 425.00, 6, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1554', '1', '12', '0', '8543', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '3.00', '15', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1556', '18', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5669';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1556, 0, 0
                    , 390.00, 18, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-02-25*390.00," WHERE transferproductid = 8544;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1556', '6', '18', '1', '8544', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5593';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1556, 0, 0
                    , 390.00, 18, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1556', '1', '18', '0', '8544', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '14.00', '32', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1557', '9', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5670';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1557, 0, 0
                    , 440.00, 8, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 6, 1557, 0, 0
                    , 440.00, -1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyprice = 440.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-02-25*440.00,1*2024-05-02*440.00," WHERE transferproductid = 8545;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1557', '6', '9', '1', '8545', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '-1', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5594';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1557, 0, 0
                    , 440.00, 8, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 1557, 0, 0
                    , 440.00, 1, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1557', '1', '9', '0', '8545', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '8.00', '17', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1555', '9', '2024-05-02', '1', '0','1985',null,null,'2024-05-02 18:54:17',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5668';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 6, 1555, 0, 0
                    , 425.00, 9, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2024-02-25*425.00," WHERE transferproductid = 8546;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1555', '6', '9', '1', '8546', 'تحويل منتجات من المخزن', 'storemovementController.php', '9.00', '0', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '5592';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1555, 0, 0
                    , 425.00, 9, 0, 0, 1, '2024-05-02 18:54:17')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 18:54:17' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1555', '1', '9', '0', '8546', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '9.00', '18', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:24:18";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 18:54:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 18:54:18', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 15:39:40";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 19:09:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 19:09:41', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE userid = 8;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:29:09";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 20:59:10", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 20:59:10', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:30:11";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:00:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 21:00:11', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:30: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-05-02 17:30:19";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:00:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:00:19', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:32:12";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:02:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:02:12', '7', 'addAndRetuen', '197.192.238.144', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06633d4b3f14bc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-05-02 21:00:19', '06633d4b3f14bc', '1', '0.00', '0', '80', '1', '1240', '1160', '1160', '0', '5', '2024-05-02 21:02:12', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1160','0','','0','0','1160','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','اضافة فاتورة مبيعات','16853', '0', '2024-05-02 21:02:12', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1160', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 16879;
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','01547', '16853', '1', '1547', '2', '410.00', '820', '0', '', '1', '2024-05-02 21:02:12', '1547', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','16879-2,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 50071;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1547, '2024-05-02', 767.09677419355, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+767.09677419355, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-05-02', 767.09677419355, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+767.09677419355, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-05-02 21:02:12' WHERE storedetailid = '5676';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1547', '5', '2', '1', '16853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '6', '7', '2024-05-02 21:02:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18331;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('340','01546', '16853', '1', '1546', '1', '420.00', '420', '0', '', '1', '2024-05-02 21:02:12', '1546', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18331-1,');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
                where sellbilldetailid = 50072;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1546, '2024-05-02', 392.90322580645, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+392.90322580645, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-05-02', 392.90322580645, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+392.90322580645, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '7', storedetaildate = '2024-05-02 21:02:12' WHERE storedetailid = '5675';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '5', '1', '1', '16853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '20', '7', '2024-05-02 21:02:12','0','0');
UPDATE save SET  savecurrentvalue = '10910',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9750.00','1160', '0', '5', 'اضافة فاتورة مبيعات', '16853', '10910', '2024-05-02 21:02:12', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-02', 1160, 980, 980
                    , 980, 980, 980, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1160, sellCostBuyPrice =sellCostBuyPrice+980
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+980, sellCostMeanBuyPrice = sellCostMeanBuyPrice+980
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+980, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+980
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-05-02', 1160, 980, 980
                    , 980, 980, 980, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1160, sellCostBuyPrice =sellCostBuyPrice+980
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+980, sellCostMeanBuyPrice = sellCostMeanBuyPrice+980
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+980, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+980
                            , 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, 1160, 980, 980
                    , 980, 980, 980, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1160, netSellCostBuyPrice = netSellCostBuyPrice+980
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+980
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+980
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+980
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+980
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06633d4b3f14bc and sellbillId = 16853 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06633d53bd4dba
-- ----------------------------------------------------------------------------------------------------

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-05-02 21:02:35', '06633d53bd4dba', '1', '0.00', '0', '0', '1', '420', '420', '-420', '0', '5', '2024-05-02 21:03:15', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-420','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5725', '0', '2024-05-02 21:03:15', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '420', '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 ('420.00', '01674', '5725', '1', '1674', '1', '420.00', '420', '0', '', '0', '0', '1674', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
                where returnsellbilldetailid = 12401;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1674, '2024-05-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 420, 420, 420
                    , 420, 420, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+420, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+420
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+420, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+420
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+420
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-05-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 420, 420, 420
                    , 420, 420, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+420, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+420
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+420, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+420
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+420
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '7', storedetaildate = '2024-05-02 21:03:15' WHERE storedetailid = '6084';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1674', '5', '1', '0', '5725', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '12.00', '13', '7', '2024-05-02 21:03:15','0','0');
UPDATE save SET  savecurrentvalue = '10490',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10910.00','420', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5725', '10490', '2024-05-02 21:03:15', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 420, 420, 420
                    , 420, 420, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+420, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+420
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+420, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+420
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+420
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-05-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 420, 420, 420
                    , 420, 420, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+420, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+420
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+420, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+420
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+420
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -420, -420, -420
                    , -420, -420, -420, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-420, netSellCostBuyPrice = netSellCostBuyPrice+-420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-420
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-420
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06633d53bd4dba and sellbillId = 5725 and returnsellbillId = 5725
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:33:16";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:03:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:03:16', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:33:37";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:03:38", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 21:03:38', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:38:24";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:08:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 21:08:24', '7', 'showDetail', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:38:30";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:08:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 21:08:30', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:42:05";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:12:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:12:05', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:43:41";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:13:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:13:41', '7', 'addAndRetuen', '197.192.238.144', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06633d7760ed87
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-05-02 21:12:06', '06633d7760ed87', '1', '0.00', '0', '0', '1', '930', '930', '930', '0', '5', '2024-05-02 21:13:41', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','930','0','','0','0','930','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','اضافة فاتورة مبيعات','16854', '0', '2024-05-02 21:13:41', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '930', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18405;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01621', '16854', '1', '1621', '1', '500.00', '500', '0', '', '0', '2024-05-02 21:13:41', '1621', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','18405-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 50073;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1621, '2024-05-02', 500, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-05-02', 500, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '7', storedetaildate = '2024-05-02 21:13:41' WHERE storedetailid = '5920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '5', '1', '1', '16854', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '7', '2024-05-02 21:13:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01584', '16854', '1', '1584', '1', '430.00', '430', '0', '', '0', '2024-05-02 21:13:41', '1584', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','16899-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50074;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1584, '2024-05-02', 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-05-02', 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 = '17', userid = '7', storedetaildate = '2024-05-02 21:13:41' WHERE storedetailid = '5686';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1584', '5', '1', '1', '16854', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '7', '2024-05-02 21:13:41','0','0');
UPDATE save SET  savecurrentvalue = '11420',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10490.00','930', '0', '5', 'اضافة فاتورة مبيعات', '16854', '11420', '2024-05-02 21:13:41', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-02', 930, 905, 905
                    , 905, 905, 905, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+930, sellCostBuyPrice =sellCostBuyPrice+905
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+905, sellCostMeanBuyPrice = sellCostMeanBuyPrice+905
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+905, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+905
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-05-02', 930, 905, 905
                    , 905, 905, 905, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+930, sellCostBuyPrice =sellCostBuyPrice+905
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+905, sellCostMeanBuyPrice = sellCostMeanBuyPrice+905
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+905, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+905
                            , 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, 930, 905, 905
                    , 905, 905, 905, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+930, netSellCostBuyPrice = netSellCostBuyPrice+905
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+905
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+905
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+905
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+905
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06633d7760ed87 and sellbillId = 16854 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:43:42";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:13:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:13:42', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:43:49";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:13:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 21:13:49', '7', '', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:43:55";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:13:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 21:13:55', '7', 'showDetail', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 17:46:29";
UPDATE user SET loginip = "197.192.238.144", lastactivetime = "2024-05-02 21:16:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 21:16:30', '7', 'addsellBill', '197.192.238.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 18:24:32";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 18:24:36";
UPDATE user SET loginip = "197.32.254.255", lastactivetime = "2024-05-02 21:54:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 21:54:36', '3', '', '197.32.254.255', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 18:24: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-05-02 18:39:36";
UPDATE user SET loginip = "197.32.254.255", lastactivetime = "2024-05-02 22:09:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 22:09:36', '3', 'addsellBill', '197.32.254.255', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:16:20";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:46:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:46:20', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:16:55";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:46:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:46:56', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:17:37";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:47:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:47:37', '7', 'add', '197.192.200.199', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('3', 'ايجار المحل', '', '6100', '2024-05-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5320',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('11420.00','6100', '1', '5', 'إضافة مصروف', '4976', '5320', '2024-05-02 22:47:37', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '6100', '6100', '2024-05-02', '7', '0', '0', '2024-05-02 22:47:37','اضافة اسم مصروف( ايجار المحل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10193', '146', '6100', '','0');
UPDATE accountstree SET name = 'ايجار', customName = 'ايجار', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '428085', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '146';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10193', '139', '6100', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3061788', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '3', expensesname = 'ايجار المحل', expensesdetails = '', expensesValue = '6100.00', expensesdate = '2024-05-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10193', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4976';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:17:37";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:47:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:47:38', '7', 'sucess', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:17:40";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:47:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:47:40', '7', 'show', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:17:40";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:47:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:47:41', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:29";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:30', '7', 'add', '197.192.200.199', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'مرتب موفق', '5 ايام  600 جنيه باقي قبض العيد', '1350', '2024-05-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3970',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5320.00','1350', '1', '5', 'إضافة مصروف', '4977', '3970', '2024-05-02 22:48:30', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1350', '1350', '2024-05-02', '7', '0', '0', '2024-05-02 22:48:30','اضافة اسم مصروف( مرتب موفق )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10194', '145', '1350', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '518240', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10194', '139', '1350', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3063138', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'مرتب موفق', expensesdetails = '5 ايام  600 جنيه باقي قبض العيد', expensesValue = '1350.00', expensesdate = '2024-05-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10194', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4977';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:31";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:31', '7', 'sucess', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:33";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:33', '7', 'show', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:40";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:40', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:53";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:53', '7', 'add', '197.192.200.199', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'مرتب عماد', '', '1500', '2024-05-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2470',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3970.00','1500', '1', '5', 'إضافة مصروف', '4978', '2470', '2024-05-02 22:48:53', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1500', '1500', '2024-05-02', '7', '0', '0', '2024-05-02 22:48:53','اضافة اسم مصروف( مرتب عماد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10195', '145', '1500', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '519740', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10195', '139', '1500', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3064638', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'مرتب عماد', expensesdetails = '', expensesValue = '1500.00', expensesdate = '2024-05-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10195', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4978';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:54";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:54', '7', 'sucess', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:56";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:56', '7', 'show', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:18:58";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:48:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:48:58', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:00";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:50:00', '7', 'add', '197.192.200.199', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('6', 'نظافه المحل', 'عمل مفاتيح اتنين نسخه', '70', '2024-05-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2400',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2470.00','70', '1', '5', 'إضافة مصروف', '4979', '2400', '2024-05-02 22:50:00', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '70', '70', '2024-05-02', '7', '0', '0', '2024-05-02 22:50:00','اضافة اسم مصروف( نظافه المحل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10196', '149', '70', '','0');
UPDATE accountstree SET name = 'ادوات مكتبية', customName = 'ادوات مكتبية', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '13672', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '149';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10196', '139', '70', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3064708', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '6', expensesname = 'نظافه المحل', expensesdetails = 'عمل مفاتيح اتنين نسخه', expensesValue = '70.00', expensesdate = '2024-05-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10196', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4979';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:01";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:50:01', '7', 'sucess', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:04";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-02 22:50:04', '7', 'show', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:06";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 22:50:06', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:10";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 22:50:11', '7', 'showDetail', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:20";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 22:50:20', '7', '', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:20:28";
UPDATE user SET loginip = "197.192.200.199", lastactivetime = "2024-05-02 22:50:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-02 22:50:28', '7', 'addsellBill', '197.192.200.199', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:31:02";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:31: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;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:31:42";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:01:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 23:01:42', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:31: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-05-02 19:31:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:01:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:01:46', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:31:46";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:01:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:01:47', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:33:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:03:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:03:02', '1', 'add', '156.210.126.78', '', '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(1986,5,1,1720,2,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 23:03:02',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6221';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1720, 0, 0
                    , 270.00, 2, 0, 0, 1, '2024-05-02 23:03:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:03:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-04-29*270.00," WHERE transferproductid = 8547;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '5', '2', '1', '8547', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '15', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-05-02' 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, 2, 0, 0, 1, '2024-05-02 23:03:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:03:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '1', '2', '0', '8547', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-05-02','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1718', '1', '2024-05-02', '1', '0','1986',null,null,'2024-05-02 23:03:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '6219';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1718, 0, 0
                    , 260.00, 1, 0, 0, 1, '2024-05-02 23:03:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:03:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-04-29*260.00," WHERE transferproductid = 8548;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '5', '1', '1', '8548', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '16', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-05-02' 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, 1, 0, 0, 1, '2024-05-02 23:03:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:03:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '1', '1', '0', '8548', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '1', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:33:03";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:03:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:03:03', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:34:58";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:04:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:04:58', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:34:58";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:04:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:04:59', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:36:22";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:06:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:06:22', '1', 'add', '156.210.126.78', '', '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(1987,1,7,956,2,'2024-05-02',1,0, '' ,0,0,0,0,0,'2024-05-02 23:06:22',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '3149';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 1, 956, 0, 0
                    , 200.00, -2, 0, 0, 1, '2024-05-02 23:06:22')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:06:22' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-05-02*200.00," WHERE transferproductid = 8549;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('956', '1', '2', '1', '8549', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-2', '1', '2024-05-02','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-05-02' WHERE storedetailid = '3181';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-02', 7, 956, 0, 0
                    , 200.00, 2, 0, 0, 1, '2024-05-02 23:06:22')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-02 23:06:22' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('956', '7', '2', '0', '8549', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-05-02','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:36:22";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:06:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-02 23:06:22', '1', 'editshow', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:54:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:24:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 23:24:02', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:54:02";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:24:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 23:24:03', '1', '', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:54:18";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:24:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 23:24:18', '1', 'show', '156.210.126.78', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:58:39";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:58:40";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:59:08";
UPDATE user SET loginip = "197.32.211.113", lastactivetime = "2024-05-02 23:29:08", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 23:29:08', '4', '', '197.32.211.113', '', '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-05-02 19:59:09";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:59:15";
UPDATE user SET loginip = "197.32.211.113", lastactivetime = "2024-05-02 23:29:15", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-02 23:29:15', '4', '', '197.32.211.113', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:59:18";
UPDATE user SET loginip = "197.32.211.113", lastactivetime = "2024-05-02 23:29:18", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 23:29:18', '4', '', '197.32.211.113', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:59:54";
UPDATE user SET loginip = "197.32.211.113", lastactivetime = "2024-05-02 23:29:54", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 23:29:54', '4', '', '197.32.211.113', '', '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-05-02 19:59:55";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 19:59:56";
UPDATE user SET loginip = "197.32.211.113", lastactivetime = "2024-05-02 23:29:56", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-02 23:29:56', '4', '', '197.32.211.113', '', '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-05-02 19:59:57";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-02 20:11:56";
UPDATE user SET loginip = "156.210.126.78", lastactivetime = "2024-05-02 23:41:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-02 23:41:56', '1', '', '156.210.126.78', '', 'DESKTOP');
