UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 06:42:39";
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-07-18 06:43:01";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 10:13:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 10:13:01', '4', '', '156.197.59.223', '', '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-07-18',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-07-18',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-07-18 06:43:04";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 06:43:18";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 10:13:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 10:13:18', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:39:41";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:09:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:09:41', '4', 'addAndRetuen', '156.197.59.223', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06698c08ea12f9
-- ----------------------------------------------------------------------------------------------------

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-07-18 10:13:18', '06698c08ea12f9', '1', '0.00', '0', '0', '1', '370', '370', '370', '0', '7', '2024-07-18 11:09:41', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','370','0','','0','0','370','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','اضافة فاتورة مبيعات','17838', '0', '2024-07-18 11:09:41', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19513;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('330','01807', '17838', '1', '1807', '1', '370', '370', '0', '', '2', '2024-07-18 11:09:41', '1807', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','19513-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 52839;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1807, '2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '4', storedetaildate = '2024-07-18 11:09:41' WHERE storedetailid = '6468';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '7', '1', '1', '17838', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '4', '2024-07-18 11:09:41','0','0');
UPDATE save SET  savecurrentvalue = '7710',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7340.00','370', '0', '7', 'اضافة فاتورة مبيعات', '17838', '7710', '2024-07-18 11:09:41', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 370, 330, 330
                    , 330, 330, 330, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+370, netSellCostBuyPrice = netSellCostBuyPrice+330
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06698c08ea12f9 and sellbillId = 17838 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:39:41";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:09:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:09:42', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:39:44";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:09:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:09:45', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:40:27";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:10:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:10:27', '4', 'addAndRetuen', '156.197.59.223', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06698cdc93d51b
-- ----------------------------------------------------------------------------------------------------

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-07-18 11:09:45', '06698cdc93d51b', '1', '0.00', '0', '0', '1', '370', '370', '-370', '0', '7', '2024-07-18 11:10:27', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-370','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '4' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','6056', '0', '2024-07-18 11:10:27', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '370', '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 ('360.00', '01777', '6056', '1', '1777', '1', '370.00', '370', '0', '', '2', '0', '1777', '0.00', '0','7','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where returnsellbilldetailid = 13043;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1777, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 360, 360, 360
                    , 360, 360, 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+370, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 360, 360, 360
                    , 360, 360, 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+370, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '28', userid = '4', storedetaildate = '2024-07-18 11:10:27' WHERE storedetailid = '6394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1777', '7', '1', '0', '6056', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '27.00', '28', '4', '2024-07-18 11:10:27','0','0');
UPDATE save SET  savecurrentvalue = '7340',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7710.00','370', '1', '7', 'اضافة فاتورة مردوات مبيعات', '6056', '7340', '2024-07-18 11:10:27', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 360, 360, 360
                    , 360, 360, 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+370, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 360, 360, 360
                    , 360, 360, 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+370, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -370, -360, -360
                    , -360, -360, -360, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-370, netSellCostBuyPrice = netSellCostBuyPrice+-360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06698cdc93d51b and sellbillId = 6056 and returnsellbillId = 6056
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:40:27";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:10:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:10:27', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:40:31";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:10:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:10:31', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:46:28";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:16:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:16:28', '4', 'addAndRetuen', '156.197.59.223', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06698cdf7ab838
-- ----------------------------------------------------------------------------------------------------

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-07-18 11:10:31', '06698cdf7ab838', '1', '0.00', '0', '0', '1', '1260', '1260', '1260', '0', '7', '2024-07-18 11:16:28', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1260','0','','0','0','1260','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','اضافة فاتورة مبيعات','17839', '0', '2024-07-18 11:16:28', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1260', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19451;
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','01803', '17839', '1', '1803', '1', '390', '390', '0', '', '2', '2024-07-18 11:16:28', '1803', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','19451-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52840;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1803, '2024-07-18', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, 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-07-18', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, 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 = '12', userid = '4', storedetaildate = '2024-07-18 11:16:28' WHERE storedetailid = '6455';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1803', '7', '1', '1', '17839', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '4', '2024-07-18 11:16:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18159;
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','01617', '17839', '1', '1617', '1', '430.01', '430', '0', '', '2', '2024-07-18 11:16:28', '1617', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','18159-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 52841;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1617, '2024-07-18', 430, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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-07-18', 430, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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 = '31', userid = '4', storedetaildate = '2024-07-18 11:16:28' WHERE storedetailid = '5884';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1617', '7', '1', '1', '17839', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32.00', '31', '4', '2024-07-18 11:16:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17039;
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 ('480','01585', '17839', '1', '1585', '1', '440.02', '440', '0', '', '2', '2024-07-18 11:16:28', '1585', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17039-1,');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 455.00
                where sellbilldetailid = 52842;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1585, '2024-07-18', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , 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-07-18', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '22', userid = '4', storedetaildate = '2024-07-18 11:16:28' WHERE storedetailid = '5756';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1585', '7', '1', '1', '17839', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23.00', '22', '4', '2024-07-18 11:16:28','0','0');
UPDATE save SET  savecurrentvalue = '8600',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7340.00','1260', '0', '7', 'اضافة فاتورة مبيعات', '17839', '8600', '2024-07-18 11:16:28', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 1260, 1190, 1240
                    , 1215, 1240, 1215, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1215
                            , 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-07-18', 1260, 1190, 1240
                    , 1215, 1240, 1215, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1215
                            , 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, 1260, 1190, 1240
                    , 1215, 1240, 1215, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1260, netSellCostBuyPrice = netSellCostBuyPrice+1190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1215
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1215
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06698cdf7ab838 and sellbillId = 17839 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:46:28";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:16:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:16:28', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:46:31";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:16:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:16:32', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:49:59";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:19:59", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:19:59', '4', 'addAndRetuen', '156.197.59.223', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06698cf6092aab
-- ----------------------------------------------------------------------------------------------------

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-07-18 11:16:32', '06698cf6092aab', '1', '0.00', '0', '0', '1', '520', '520', '-520', '0', '7', '2024-07-18 11:19:59', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-520','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '4' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','6057', '0', '2024-07-18 11:19:59', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '520', '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 ('250.00', '01741', '6057', '1', '1741', '2', '260', '520', '0', '', '2', '0', '1741', '0.00', '0','7','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 255.00
                where returnsellbilldetailid = 13044;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1741, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 500, 520, 510
                    , 520, 510, 0, 0, 2)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+2;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 500, 520, 510
                    , 520, 510, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '4', storedetaildate = '2024-07-18 11:19:59' WHERE storedetailid = '6268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '7', '2', '0', '6057', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '9.00', '11', '4', '2024-07-18 11:19:59','0','0');
UPDATE save SET  savecurrentvalue = '8080',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8600.00','520', '1', '7', 'اضافة فاتورة مردوات مبيعات', '6057', '8080', '2024-07-18 11:19:59', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 500, 520, 510
                    , 520, 510, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                        , 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 500, 520, 510
                    , 520, 510, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+500, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -520, -500, -520
                    , -510, -520, -510, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-520, netSellCostBuyPrice = netSellCostBuyPrice+-500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-520
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-510
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-520
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-510
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06698cf6092aab and sellbillId = 6057 and returnsellbillId = 6057
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:49:59";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:19:59", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:19:59', '4', 'addsellBill', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 07:50:01";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:20:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 11:20:01', '4', '', '156.197.59.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 08:00:57";
UPDATE user SET loginip = "156.197.59.223", lastactivetime = "2024-07-18 11:30:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 11:30:57', '4', 'addsellBill', '156.197.59.223', '', '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-07-18 11:16:16";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 14:46:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 14:46:16', '1', '', '156.210.106.230', '', '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-07-18 11:16: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-07-18 11:35:42";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:05:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:05:42', '1', 'addsellBill', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:35:42";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:05:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:05:42', '1', 'addsellBill', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:36:51";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:06:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:06:51', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:36:51";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:06:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:06:51', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:36:51";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:06:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:06:52', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:37:04";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:07:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:07:04', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE product SET productName = '1005 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510.00', productSellHalfPrice = '440.00', productDate = '2024-05-31', conditions = '0', userId = '1', limitamount = '0', parcode = '01772',type ='0', expireDate = '0' , dailyentryId = '10392',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '18.60',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1772';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1772, 1,'2024-07-18 15:07:22',1)
                ON DUPLICATE KEY UPDATE productid = 1772, edited = 1, sysdate = '2024-07-18 15:07:22', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:37:29";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:07:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:07:29', '1', 'addsellBill', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:37:29";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:07:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:07:29', '1', 'addsellBill', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:38:29";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:08:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:08:29', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:38:39";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:08:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:08:40', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر1006ديدج', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510.00', productSellHalfPrice = '440.00', productDate = '2024-05-31', conditions = '0', userId = '1', limitamount = '0', parcode = '01773',type ='0', expireDate = '0' , dailyentryId = '10393',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '18.60',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1773';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1773, 1,'2024-07-18 15:08:52',1)
                ON DUPLICATE KEY UPDATE productid = 1773, edited = 1, sysdate = '2024-07-18 15:08:52', userid = 1;
UPDATE product SET productName = '1006 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510.00', productSellHalfPrice = '440.00', productDate = '2024-05-31', conditions = '0', userId = '1', limitamount = '0', parcode = '01773',type ='0', expireDate = '0' , dailyentryId = '10393',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '18.60',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1773';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1773, 1,'2024-07-18 15:09:13',1)
                ON DUPLICATE KEY UPDATE productid = 1773, edited = 1, sysdate = '2024-07-18 15:09:13', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:40:09";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:10:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:10:09', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE product SET productName = '1004 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '440.00', productSellAllPrice = '460.00', productSellUnitPrice = '490.00', productSellHalfPrice = '470.00', productDate = '2024-05-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01756',type ='0', expireDate = '0' , dailyentryId = '10256',isService = '0',isOptic = '0',lastbuyprice = '440.00',lastbuyprice_withDiscount = '440',meanbuyprice = '440.00',meanbuyprice_withDiscount = '440' , productbuypricereal = '440.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.55' , buyhalf_precentage = '6.82' , buypart_precentage = '11.36',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1756';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1756, 1,'2024-07-18 15:10:29',1)
                ON DUPLICATE KEY UPDATE productid = 1756, edited = 1, sysdate = '2024-07-18 15:10:29', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:40:33";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:10:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:10:33', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:44:10";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:14:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:14:11', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE product SET productName = '666 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '460.00', productSellAllPrice = '460.00', productSellUnitPrice = '510.00', productSellHalfPrice = '470.00', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01681',type ='0', expireDate = '0' , dailyentryId = '9900',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '460.00',meanbuyprice_withDiscount = '460' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1681';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1681, 1,'2024-07-18 15:14:37',1)
                ON DUPLICATE KEY UPDATE productid = 1681, edited = 1, sysdate = '2024-07-18 15:14:37', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:45:23";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:15:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-18 15:15:23', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE product SET productName = '1007 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510.00', productSellHalfPrice = '440.00', productDate = '2024-05-31', conditions = '0', userId = '1', limitamount = '0', parcode = '01771',type ='0', expireDate = '0' , dailyentryId = '10391',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '18.60',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1771';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1771, 1,'2024-07-18 15:15:35',1)
                ON DUPLICATE KEY UPDATE productid = 1771, edited = 1, sysdate = '2024-07-18 15:15:35', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:47:15";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:17:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:17:15', '1', 'addAndRetuen', '156.210.106.230', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066990581b858c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(347,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-07-18 15:07:29', '066990581b858c', '347', '87680.00', '39050', '0', '1', '48630', '48630', '0', '-48630', '1', '2024-07-18 15:17:15', '', '1', '0', 'سنتر الشيخ الاسكنداريه','1', '1', '5', '0', 'سنتر الشيخ الاسكنداريه', '111', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '39050', userid = '1' WHERE clientid = '347';
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 ('347','87680.00','48630','1','اضافة فاتورة مردوات مبيعات','6058', '39050', '2024-07-18 15:17:15', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '48630', '0', null, '0', null, null,'', '0','1','1','48630','1');
UPDATE client SET  inUse = 0 where clientid = 347;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01772', '6058', '1', '1772', '24', '430.00', '10320', '0', '', '0', '0', '1772', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 13045;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1772, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 10320, 10320, 10320, 10320
                    , 10320, 10320, 0, 0, 24)
                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+10320, returnSellCostBuyPrice = returnSellCostBuyPrice+10320, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+10320
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+10320, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+10320
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+10320
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+24;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 10320, 10320, 10320, 10320
                    , 10320, 10320, 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+10320, returnSellCostBuyPrice = returnSellCostBuyPrice+10320, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+10320
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+10320, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+10320
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+10320
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '1', '24', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3.00', '27', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01773', '6058', '1', '1773', '9', '430.00', '3870', '0', '', '0', '0', '1773', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 13046;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1773, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3870, 3870, 3870, 3870
                    , 3870, 3870, 0, 0, 9)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+3870, returnSellCostBuyPrice = returnSellCostBuyPrice+3870, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3870
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3870, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3870
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3870
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+9;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3870, 3870, 3870, 3870
                    , 3870, 3870, 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+3870, returnSellCostBuyPrice = returnSellCostBuyPrice+3870, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3870
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3870, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3870
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3870
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6365';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '1', '9', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3.00', '12', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01697', '6058', '1', '1697', '12', '430.00', '5160', '0', '', '0', '0', '1697', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 420.00
                where returnsellbilldetailid = 13047;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1697, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 5160, 5160, 5400, 5040
                    , 5400, 5040, 0, 0, 12)
                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+5160, returnSellCostBuyPrice = returnSellCostBuyPrice+5160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+5400
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+5040, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+5400
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+5040
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+12;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 5160, 5160, 5400, 5040
                    , 5400, 5040, 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+5160, returnSellCostBuyPrice = returnSellCostBuyPrice+5160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+5400
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+5040, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+5400
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+5040
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6148';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '1', '12', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '20.00', '32', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('440.00', '01756', '6058', '1', '1756', '22', '460.00', '10120', '0', '', '0', '0', '1756', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
                where returnsellbilldetailid = 13048;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1756, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 10120, 9680, 9680, 9680
                    , 9680, 9680, 0, 0, 22)
                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+10120, returnSellCostBuyPrice = returnSellCostBuyPrice+9680, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+9680
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+9680, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+9680
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+9680
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+22;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 10120, 9680, 9680, 9680
                    , 9680, 9680, 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+10120, returnSellCostBuyPrice = returnSellCostBuyPrice+9680, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+9680
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+9680, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+9680
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+9680
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '54', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6305';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '1', '22', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '32.00', '54', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01701', '6058', '1', '1701', '14', '430.00', '6020', '0', '', '0', '0', '1701', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 363.88, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 363.88
                where returnsellbilldetailid = 13049;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1701, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 6020, 6020, 14, 5094.32
                    , 14, 5094.32, 0, 0, 14)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+6020, returnSellCostBuyPrice = returnSellCostBuyPrice+6020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+14
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+5094.32, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+14
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+5094.32
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+14;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 6020, 6020, 14, 5094.32
                    , 14, 5094.32, 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+6020, returnSellCostBuyPrice = returnSellCostBuyPrice+6020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+14
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+5094.32, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+14
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+5094.32
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6157';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '1', '14', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-16.00', '-2', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('460.00', '01681', '6058', '1', '1681', '8', '460.00', '3680', '0', '', '0', '0', '1681', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
                where returnsellbilldetailid = 13050;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1681, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3680, 3680, 3680, 3680
                    , 3680, 3680, 0, 0, 8)
                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+3680, returnSellCostBuyPrice = returnSellCostBuyPrice+3680, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3680
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3680, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3680
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3680
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+8;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3680, 3680, 3680, 3680
                    , 3680, 3680, 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+3680, returnSellCostBuyPrice = returnSellCostBuyPrice+3680, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3680
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3680, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3680
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3680
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6092';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '1', '8', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '8', '1', '2024-07-18 15:17:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01771', '6058', '1', '1771', '22', '430.00', '9460', '0', '', '0', '0', '1771', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 13051;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1771, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 9460, 9460, 9460, 9460
                    , 9460, 9460, 0, 0, 22)
                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+9460, returnSellCostBuyPrice = returnSellCostBuyPrice+9460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+9460
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+9460, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+9460
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+9460
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+22;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 9460, 9460, 9460, 9460
                    , 9460, 9460, 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+9460, returnSellCostBuyPrice = returnSellCostBuyPrice+9460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+9460
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+9460, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+9460
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+9460
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-18 15:17:15' WHERE storedetailid = '6363';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '1', '22', '0', '6058', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4.00', '26', '1', '2024-07-18 15:17:15','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 48630, 48190, 42424, 47144.32
                    , 42424, 47144.32, 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+48630, returnSellCostBuyPrice = returnSellCostBuyPrice+48190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+42424
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+47144.32, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+42424
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+47144.32
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (347, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 48630, 48190, 42424, 47144.32
                    , 42424, 47144.32, 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+48630, returnSellCostBuyPrice = returnSellCostBuyPrice+48190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+42424
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+47144.32, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+42424
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+47144.32
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -48630, -48190, -42424
                    , -47144.32, -42424, -47144.32, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-48630, netSellCostBuyPrice = netSellCostBuyPrice+-48190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-42424
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-47144.32
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-42424
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-47144.32
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066990581b858c and sellbillId = 6058 and returnsellbillId = 6058
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:47:16";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:17:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:17:16', '1', 'addsellBill', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:52:29";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:22:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 15:22:29', '1', '', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:53:04";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:23:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-07-18 15:23:04', '1', 'all', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:53:20";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:23:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-07-18 15:23:21', '1', 'all', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:54:06";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:24:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 15:24:06', '1', 'add', '156.210.106.230', '', '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 =26423
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(347,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '37050' , clientdate = '2024-07-18 15:24:06', userid = '1' WHERE clientid = '347';
UPDATE client SET  inUse = 0 where clientid = 347;
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 ('347','39050.00','2000','1','ايصال تحصيل (( قبض من عميل ))','26423', '37050', '2024-07-18 15:22:29', '1', 'clientPayedDeptController.php', '   ليد طنطاوي', '2000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '567185',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('565185.00','2000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '26423', '567185', '2024-07-18 15:24:06', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '2000', '2000', '2024-07-18', '1', '0', '0', '2024-07-18 15:24:06','اضافة ايصال سداد للعميل سنتر الشيخ الاسكنداريه','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10691', '54', '2000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '374879', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10691', '424', '2000', '','0');
UPDATE accountstree SET name = 'سنتر الشيخ الاسكنداريه', customName = 'سنتر الشيخ الاسكنداريه', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2023-03-16', itemtype2 = '1', theValue = '-53760', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '424';
UPDATE clientdebtchange SET clientid = '347', clientdebtchangebefore = '39050.00', clientdebtchangeamount = '2000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '26423', clientdebtchangeafter = '37050.00', clientdebtchangedate = '2024-07-18 15:22:29', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ليد طنطاوي', totalOperationCost = '2000.00',discount='', reciptid=null, dailyentryid = '10691',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '26423';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:54:06";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:24:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 15:24:06', '1', 'editprint2', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:56:28";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:26:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-07-18 15:26:30', '1', 'all', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 11:59:39";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:29:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-07-18 15:29:39', '1', 'all', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:06:45";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 15:36:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 15:36:45', '1', '', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:07:22";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:08:30";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:08:39";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:38:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 15:38:40', '4', '', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:08:44";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:38:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:38:44', '4', 'showDetail', '197.35.233.242', '', '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-07-18 12:08:48";
UPDATE user SET loginip = "197.192.203.75", lastactivetime = "2024-07-18 15:38:48", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 15:38:48', '7', '', '197.192.203.75', '', '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-07-18 12:08:48";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:00";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 15:39:00', '4', '', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:04";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:04";
UPDATE user SET loginip = "197.192.203.75", lastactivetime = "2024-07-18 15:39:04", deviceType = "DESKTOP" WHERE userid = 7;
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:04", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:39:04', '7', 'addsellBill', '197.192.203.75', '', 'DESKTOP');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:39:05', '4', 'addsellBill', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:08";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 15:39:08', '4', '', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:35";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:35", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 15:39:35', '4', 'add', '197.35.233.242', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'مصروف احمد نبروه', '', '100', '2024-07-18', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '7980',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8080.00','100', '1', '7', 'إضافة مصروف', '5218', '7980', '2024-07-18 15:39:35', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2024-07-18', '4', '0', '0', '2024-07-18 15:39:35','اضافة اسم مصروف( مصروف احمد نبروه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10692', '160', '100', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4572865', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10692', '141', '100', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2204342', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'مصروف احمد نبروه', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-07-18', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10692', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5218';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:35";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 15:39:36', '4', 'sucess', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:37";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 15:39:37', '4', 'show', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:38";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:39:38', '4', 'addsellBill', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:41";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:39:41', '4', 'addsellBill', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:46";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 15:39:46', '4', '', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:09:50";
UPDATE user SET loginip = "197.35.233.242", lastactivetime = "2024-07-18 15:39:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:39:50', '4', 'addsellBill', '197.35.233.242', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:10:00";
UPDATE user SET loginip = "197.192.203.75", lastactivetime = "2024-07-18 15:40:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:40:00', '7', 'addsellBill', '197.192.203.75', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:12:13";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:12:23";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:12:25";
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-07-18 12:12:39";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 15:42:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 15:42:39', '7', '', '197.192.195.54', '', '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-07-18 12:12:40";
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-07-18 12:12:47";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 15:42:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:42:47', '7', 'addsellBill', '197.192.195.54', '', '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-07-18 12:16:08";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 15:46:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 15:46:08', '7', '', '197.192.195.54', '', '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-07-18 12:16:08";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:17:06";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 15:47:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:47:06', '7', 'addsellBill', '197.192.195.54', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:17:12";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 15:47:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 15:47:12', '7', 'addsellBill', '197.192.195.54', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 12:58:14";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 16:28:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 16:28:14', '7', 'addsellBill', '197.192.195.54', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:04:06";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:34:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 16:34:06', '1', 'add', '156.210.106.230', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6475';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1740', '5', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '11.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6474';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('957', '5', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '11.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6458';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1727', '5', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '27.00', '35', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6457';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1804', '5', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '11.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1779', '5', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '11.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1789', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '10.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6422';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '5', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '13.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6421';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '5', '17', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '17.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '5', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '8.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '24.00', '26', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '5', '14', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '14.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '17.00', '22', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '5', '16', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '16.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6370';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '5', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-1.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6369';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6367';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1768', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6366';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1767', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6353';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1764', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('353', '5', '14', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '14.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6329';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '2.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6328';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '4.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '5', '13', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-4.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1755', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '18.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6325';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '5', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '3.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '5', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-5.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6323';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1696', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6319';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1759', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6318';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1758', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '39', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6287';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1750', '5', '39', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '39.00', '39', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1523', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1521', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6277';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1529', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1570', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6224';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-2.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6223';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '5', '9', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '9.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6221';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '13.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6220';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1719', '5', '10', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '10.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6219';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '5', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '8.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6218';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1717', '5', '36', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '36.00', '36', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6217';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1716', '5', '16', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '16.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '5', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6168';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '5', '16', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '16.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' 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-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6059';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1660', '5', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '14.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6058';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6057';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1662', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '10.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6056';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1665', '5', '26', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '26.00', '26', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6055';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '1.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6054';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1423', '5', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '3.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6006';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1650', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '1.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6005';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1649', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '4.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6004';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1648', '5', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '5.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6003';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1646', '5', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5995';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1645', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5991';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1644', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5990';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1641', '5', '7', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '7.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5989';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1640', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5988';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '2.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5987';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1643', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5986';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1639', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5929';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1633', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1631', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5919';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1626', '5', '23', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '23.00', '23', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5918';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1623', '5', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '15.00', '15', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5917';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1629', '5', '13', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '13.00', '13', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5916';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1630', '5', '16', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '16.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5915';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1625', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '22.00', '21', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5914';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1624', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '13.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5913';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1622', '5', '14', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '14.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1617', '5', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '39.00', '35', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5794';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('216', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5721';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1552', '5', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5720';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1551', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5719';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1553', '5', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '15.00', '15', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5718';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1549', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '12.00', '13', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' 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', '11.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5710';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1587', '5', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '4.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5709';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1519', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5697';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '10.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5696';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5695';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1580', '5', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '26.00', '23', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5694';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '5', '6', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '6.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5693';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1576', '5', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '18.00', '15', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5692';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1575', '5', '17', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '17.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5691';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1574', '5', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5690';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1585', '5', '36', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '36.00', '36', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '25.00', '21', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '33', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5687';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1582', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '31.00', '33', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5686';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1584', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '10.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5685';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1579', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '6.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5680';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1554', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5677';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1567', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5675';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1546', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5449';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1479', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5443';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1473', '5', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1402', '5', '7', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '7.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4990';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1343', '5', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4943';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1294', '5', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '8.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4907';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1322', '5', '14', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4904';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1325', '5', '13', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '14.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4810';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1282', '5', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:04:21";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:34:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 16:34:21', '1', 'show', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:05:13";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:35:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:35:13', '1', '', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:07:58";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:37:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:37:58', '1', 'add', '156.210.106.230', '', '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(2164,1,5,1756,22,'2024-07-18',1,0, '' ,0,0,0,0,0,'2024-07-18 16:37:58',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6305';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1756, 0, 0
                    , 440.00, -22, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 440.00,
                        buyQuantity =buyQuantity+-22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-07-18*440.00," WHERE transferproductid = 8979;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '1', '22', '1', '8979', 'تحويل منتجات من المخزن', 'storemovementController.php', '54.00', '32', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6327';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1756, 0, 0
                    , 440.00, 22, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '5', '22', '0', '8979', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '9.00', '31', '1', '2024-07-18','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', '1697', '6', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6148';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1697, 0, 0
                    , 450.00, -6, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-07-18*450.00," WHERE transferproductid = 8980;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '1', '6', '1', '8980', 'تحويل منتجات من المخزن', 'storemovementController.php', '32.00', '26', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6324';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1697, 0, 0
                    , 450.00, 6, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '5', '6', '0', '8980', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '7.00', '13', '1', '2024-07-18','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', '1681', '8', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6092';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1681, 0, 0
                    , 460.00, -8, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 460.00,
                        buyQuantity =buyQuantity+-8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-07-18*460.00," WHERE transferproductid = 8981;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '1', '8', '1', '8981', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6099';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1681, 0, 0
                    , 460.00, 8, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '5', '8', '0', '8981', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '8', '1', '2024-07-18','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', '1771', '10', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6363';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1771, 0, 0
                    , 430.00, -10, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-07-18*430.00," WHERE transferproductid = 8982;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '1', '10', '1', '8982', 'تحويل منتجات من المخزن', 'storemovementController.php', '26.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6368';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1771, 0, 0
                    , 430.00, 10, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '5', '10', '0', '8982', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '10', '1', '2024-07-18','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', '1773', '3', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6365';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1773, 0, 0
                    , 430.00, -3, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2024-07-18*430.00," WHERE transferproductid = 8983;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '1', '3', '1', '8983', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6369';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1773, 0, 0
                    , 430.00, 3, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '5', '3', '0', '8983', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '3', '1', '2024-07-18','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', '1772', '19', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6364';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1772, 0, 0
                    , 430.00, -19, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-07-18*430.00," WHERE transferproductid = 8984;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '1', '19', '1', '8984', 'تحويل منتجات من المخزن', 'storemovementController.php', '27.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6370';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1772, 0, 0
                    , 430.00, 19, 0, 0, 1, '2024-07-18 16:37:58')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:58' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '5', '19', '0', '8984', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '21', '1', '2024-07-18','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', '1701', '14', '2024-07-18', '1', '0','2164',null,null,'2024-07-18 16:37:58',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6157';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1701, 0, 0
                    , 1.00, -14, 0, 0, 1, '2024-07-18 16:37:59')
                ON DUPLICATE KEY UPDATE buyprice = 1.00,
                        buyQuantity =buyQuantity+-14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:59' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-07-18*1.00," WHERE transferproductid = 8985;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '1', '14', '1', '8985', 'تحويل منتجات من المخزن', 'storemovementController.php', '-2.00', '-16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6169';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 5, 1701, 0, 0
                    , 1.00, 14, 0, 0, 1, '2024-07-18 16:37:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:37:59' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '5', '14', '0', '8985', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '14', '1', '2024-07-18','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:07:59";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:37:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:37:59', '1', 'editshow', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:09:01";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:39:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:39:02', '1', '', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:10:45";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:40:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:40:45', '1', 'add', '156.210.106.230', '', '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(2165,1,6,1772,5,'2024-07-18',1,0, '' ,0,0,0,0,0,'2024-07-18 16:40:46',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6364';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1772, 0, 0
                    , 430.00, -5, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "5*2024-07-18*430.00," WHERE transferproductid = 8986;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '1', '5', '1', '8986', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6376';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 6, 1772, 0, 0
                    , 430.00, 5, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '6', '5', '0', '8986', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '7', '1', '2024-07-18','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1773', '6', '2024-07-18', '1', '0','2165',null,null,'2024-07-18 16:40:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6365';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1773, 0, 0
                    , 430.00, -6, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-07-18*430.00," WHERE transferproductid = 8987;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '1', '6', '1', '8987', 'تحويل منتجات من المخزن', 'storemovementController.php', '9.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6375';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 6, 1773, 0, 0
                    , 430.00, 6, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '6', '6', '0', '8987', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '7', '1', '2024-07-18','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1697', '6', '2024-07-18', '1', '0','2165',null,null,'2024-07-18 16:40:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6148';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1697, 0, 0
                    , 450.00, -6, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-07-18*450.00," WHERE transferproductid = 8988;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '1', '6', '1', '8988', 'تحويل منتجات من المخزن', 'storemovementController.php', '26.00', '20', '1', '2024-07-18','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1697', '6', '6', '1', '2024-07-18');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 6, 1697, 0, 0
                    , 450.00, 6, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '6', '6', '0', '8988', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '6', '1', '2024-07-18','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1771', '12', '2024-07-18', '1', '0','2165',null,null,'2024-07-18 16:40:46',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6363';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1771, 0, 0
                    , 430.00, -12, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-07-18*430.00," WHERE transferproductid = 8989;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '1', '12', '1', '8989', 'تحويل منتجات من المخزن', 'storemovementController.php', '16.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6374';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 6, 1771, 0, 0
                    , 430.00, 12, 0, 0, 1, '2024-07-18 16:40:46')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:40:46' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '6', '12', '0', '8989', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2024-07-18','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:10:46";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:40:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:40:46', '1', 'editshow', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:12:00";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:42:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:42:00', '1', '', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:12:19";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:42:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:42:19', '1', 'add', '156.210.106.230', '', '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(2166,5,6,1785,8,'2024-07-18',1,0, '' ,0,0,0,0,0,'2024-07-18 16:42:19',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6419';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1785, 0, 0
                    , 360.00, 5, 0, 0, 1, '2024-07-18 16:42:19')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-5, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:42:19' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-11', 5, 1785, 0, 0
                    , 360.00, 3, 0, 0, 1, '2024-07-18 16:42:19')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-3, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:42:19' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "5*2024-06-10*360.00,3*2024-06-11*360.00," WHERE transferproductid = 8990;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '5', '8', '1', '8990', 'تحويل منتجات من المخزن', 'storemovementController.php', '26.00', '18', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6413';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1785, 0, 0
                    , 360.00, 5, 0, 0, 1, '2024-07-18 16:42:19')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:42:19' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-11', 6, 1785, 0, 0
                    , 360.00, 3, 0, 0, 1, '2024-07-18 16:42:19')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 16:42:19' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '6', '8', '0', '8990', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '7.00', '15', '1', '2024-07-18','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:12:20";
UPDATE user SET loginip = "156.210.106.230", lastactivetime = "2024-07-18 16:42:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 16:42:20', '1', 'editshow', '156.210.106.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:21:30";
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-07-18 13:21:35";
UPDATE user SET loginip = "197.35.224.10", lastactivetime = "2024-07-18 16:51:35", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 16:51:35', '4', '', '197.35.224.10', '', '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-07-18 13:21: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-07-18 13:21:38";
UPDATE user SET loginip = "197.35.224.10", lastactivetime = "2024-07-18 16:51:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 16:51:38', '4', 'addsellBill', '197.35.224.10', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:26:31";
UPDATE user SET loginip = "197.35.224.10", lastactivetime = "2024-07-18 16:56:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 16:56:32', '4', 'addAndRetuen', '197.35.224.10', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066991dea3db8e
-- ----------------------------------------------------------------------------------------------------

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-07-18 16:51:38', '066991dea3db8e', '1', '0.00', '0', '0', '1', '475', '475', '475', '0', '7', '2024-07-18 16:56:32', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','475','0','','0','0','475','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','اضافة فاتورة مبيعات','17840', '0', '2024-07-18 16:56:32', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '475', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18157;
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 ('395','01704', '17840', '1', '1704', '1', '475', '475', '0', '', '1', '2024-07-18 16:56:32', '1704', '0.00', '0', '7','0','','','0','0','0','0','0','0','1','0','','18157-1,');
UPDATE sellbilldetail SET  lastbuyprice = 395.00 , meanbuyprice = 395.00, lastbuyprice_withDiscount = 395.00, meanbuyprice_withDiscount = 395.00
                where sellbilldetailid = 52843;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1704, '2024-07-18', 475, 395, 395
                    , 395, 395, 395, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , 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-07-18', 475, 395, 395
                    , 395, 395, 395, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '4', storedetaildate = '2024-07-18 16:56:32' WHERE storedetailid = '6174';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1704', '7', '1', '1', '17840', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '4', '2024-07-18 16:56:32','0','0');
UPDATE save SET  savecurrentvalue = '8455',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7980.00','475', '0', '7', 'اضافة فاتورة مبيعات', '17840', '8455', '2024-07-18 16:56:32', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 475, 395, 395
                    , 395, 395, 395, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , 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-07-18', 475, 395, 395
                    , 395, 395, 395, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+395
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+395
                            , 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, 475, 395, 395
                    , 395, 395, 395, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+475, netSellCostBuyPrice = netSellCostBuyPrice+395
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+395
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+395
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+395
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+395
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066991dea3db8e and sellbillId = 17840 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 13:26:32";
UPDATE user SET loginip = "197.35.224.10", lastactivetime = "2024-07-18 16:56:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 16:56:32', '4', 'addsellBill', '197.35.224.10', '', '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-07-18 13:32:36";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 17:02:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 17:02:36', '7', '', '197.192.195.54', '', '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-07-18 13:32: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-07-18 13:32:45";
UPDATE user SET loginip = "197.192.195.54", lastactivetime = "2024-07-18 17:02:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:02:45', '7', 'addsellBill', '197.192.195.54', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:18:58";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:18:59";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:19:01";
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-07-18 14:19:25";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 17:49:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 17:49:25', '1', '', '156.210.74.201', '', '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-07-18 14:19:25";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:19:35";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 17:49:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 17:49:35', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:21:39";
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-07-18 14:22:18";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:52:18", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 17:52:18', '7', '', '197.192.204.250', '', '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-07-18 14:22: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-07-18 14:24:18";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:54:18", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:54:18', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:00";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:00', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:15";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:15', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992cc4b28b9
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:55:00', '066992cc4b28b9', '1', '0.00', '0', '0', '1', '510', '510', '510', '0', '5', '2024-07-18 17:55:15', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','510','0','','0','0','510','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','اضافة فاتورة مبيعات','17841', '0', '2024-07-18 17:55:15', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '510', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16917;
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','01580', '17841', '1', '1580', '1', '510', '510', '0', '', '1', '2024-07-18 17:55:15', '1580', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','16917-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 52844;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1580, '2024-07-18', 510, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, 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-07-18', 510, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, 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 = '22', userid = '7', storedetaildate = '2024-07-18 17:55:15' WHERE storedetailid = '5695';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1580', '5', '1', '1', '17841', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23.00', '22', '7', '2024-07-18 17:55:15','0','0');
UPDATE save SET  savecurrentvalue = '9130',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8620.00','510', '0', '5', 'اضافة فاتورة مبيعات', '17841', '9130', '2024-07-18 17:55:15', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 510, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 510, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 510, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+510, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992cc4b28b9 and sellbillId = 17841 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:16";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:16', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:24";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:24', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:50";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:50', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992cdc7c520
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:55:24', '066992cdc7c520', '1', '0.00', '0', '20', '1', '430', '410', '-410', '0', '5', '2024-07-18 17:55:50', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-410','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','اضافة فاتورة مردوات مبيعات','6059', '0', '2024-07-18 17:55:50', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '410', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('350.00', '01761', '6059', '1', '1761', '1', '430', '430', '0', '', '1', '0', '1761', '0.00', '0','5','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where returnsellbilldetailid = 13052;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 450, 350, 350, 350
                    , 350, 350, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+450, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 450, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+450, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '7', storedetaildate = '2024-07-18 17:55:50' WHERE storedetailid = '6371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '5', '1', '0', '6059', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '16.00', '17', '7', '2024-07-18 17:55:50','0','0');
UPDATE save SET  savecurrentvalue = '8720',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9130.00','410', '1', '5', 'اضافة فاتورة مردوات مبيعات', '6059', '8720', '2024-07-18 17:55:50', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 410, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+410, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 410, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+410, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -410, -350, -350
                    , -350, -350, -350, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-410, netSellCostBuyPrice = netSellCostBuyPrice+-350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992cdc7c520 and sellbillId = 6059 and returnsellbillId = 6059
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:51";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:51', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:25:58";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:55:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:55:58', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:26:15";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:56:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:56:16', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992cfe9c8c2
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:55:58', '066992cfe9c8c2', '1', '0.00', '0', '0', '1', '430', '430', '430', '0', '5', '2024-07-18 17:56:16', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','430','0','','0','0','430','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','اضافة فاتورة مبيعات','17842', '0', '2024-07-18 17:56:16', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '430', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19481;
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','01804', '17842', '1', '1804', '1', '430', '430', '0', '', '1', '2024-07-18 17:56:16', '1804', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','19481-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52845;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1804, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '7', storedetaildate = '2024-07-18 17:56:16' WHERE storedetailid = '6457';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1804', '5', '1', '1', '17842', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2024-07-18 17:56:16','0','0');
UPDATE save SET  savecurrentvalue = '9150',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8720.00','430', '0', '5', 'اضافة فاتورة مبيعات', '17842', '9150', '2024-07-18 17:56:16', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 430, 350, 350
                    , 350, 350, 350, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+430, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992cfe9c8c2 and sellbillId = 17842 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:26:17";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:56:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:56:17', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:26:54";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:56:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:56:54', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992d11c307b
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:56:17', '066992d11c307b', '1', '0.00', '0', '0', '1', '460', '460', '460', '0', '5', '2024-07-18 17:56:54', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','460','0','','0','0','460','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','17843', '0', '2024-07-18 17:56:54', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17685;
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 ('500','01642', '17843', '1', '1642', '1', '460.00', '460', '0', '', '2', '2024-07-18 17:56:54', '1642', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','17685-1,');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 52846;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1642, '2024-07-18', 460, 450, 500
                    , 475, 500, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, 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-07-18', 460, 450, 500
                    , 475, 500, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, 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 = '2', userid = '7', storedetaildate = '2024-07-18 17:56:54' WHERE storedetailid = '5988';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '5', '1', '1', '17843', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '7', '2024-07-18 17:56:54','0','0');
UPDATE save SET  savecurrentvalue = '9610',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9150.00','460', '0', '5', 'اضافة فاتورة مبيعات', '17843', '9610', '2024-07-18 17:56:54', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 460, 450, 500
                    , 475, 500, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 460, 450, 500
                    , 475, 500, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 460, 450, 500
                    , 475, 500, 475, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+475
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+475
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992d11c307b and sellbillId = 17843 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:26:55";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:56:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:56:55', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:27:03";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:57:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:57:03', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:27:22";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:57:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:57:22', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992d4008c61
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:57:04', '066992d4008c61', '1', '0.00', '0', '0', '1', '430', '430', '-430', '0', '5', '2024-07-18 17:57:22', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-430','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','اضافة فاتورة مردوات مبيعات','6060', '0', '2024-07-18 17:57:22', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '430', '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', '01576', '6060', '1', '1576', '1', '430.00', '430', '0', '', '2', '0', '1576', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 420.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 420.00, meanbuyprice_withDiscount = 420.00
                where returnsellbilldetailid = 13053;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1576, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 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+430, 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 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+430, returnSellCostBuyPrice = returnSellCostBuyPrice+420, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+420
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+420, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+420
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+420
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '7', storedetaildate = '2024-07-18 17:57:22' WHERE storedetailid = '5693';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1576', '5', '1', '0', '6060', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '15.00', '16', '7', '2024-07-18 17:57:22','0','0');
UPDATE save SET  savecurrentvalue = '9180',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9610.00','430', '1', '5', 'اضافة فاتورة مردوات مبيعات', '6060', '9180', '2024-07-18 17:57:22', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 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+430, 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 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+430, 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, -430, -420, -420
                    , -420, -420, -420, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-430, netSellCostBuyPrice = netSellCostBuyPrice+-420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-420
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-420
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992d4008c61 and sellbillId = 6060 and returnsellbillId = 6060
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:27:23";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:57:23", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:57:23', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:27:29";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:57:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:57:29', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:28:14";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:58:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:58:14', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992d598cc62
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:57:29', '066992d598cc62', '1', '0.00', '0', '0', '1', '1750', '1750', '1750', '0', '5', '2024-07-18 17:58:14', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1750','0','','0','0','1750','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','اضافة فاتورة مبيعات','17844', '0', '2024-07-18 17:58:14', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1750', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19265;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17844', '1', '1577', '2', '460.00', '920', '0', '', '2', '2024-07-18 17:58:14', '1577', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19265-2,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52847;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-18', 920, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 920, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-07-18 17:58:14' WHERE storedetailid = '5697';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '2', '1', '17844', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '6', '7', '2024-07-18 17:58:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19251;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('1','01634', '17844', '1', '1634', '1', '440.00', '440', '0', '', '2', '2024-07-18 17:58:14', '1634', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19251-1,');
UPDATE sellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 366.32, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 366.32
                where sellbilldetailid = 52848;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1634, '2024-07-18', 440, 430, 1
                    , 366.32, 1, 366.32, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1, sellCostMeanBuyPrice = sellCostMeanBuyPrice+366.32
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+366.32
                            , 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-07-18', 440, 430, 1
                    , 366.32, 1, 366.32, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1, sellCostMeanBuyPrice = sellCostMeanBuyPrice+366.32
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+366.32
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2024-07-18 17:58:14' WHERE storedetailid = '6422';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '5', '1', '1', '17844', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2024-07-18 17:58:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19279;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01779', '17844', '1', '1779', '1', '390.00', '390', '0', '', '2', '2024-07-18 17:58:14', '1779', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19279-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52849;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1779, '2024-07-18', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '7', storedetaildate = '2024-07-18 17:58:14' WHERE storedetailid = '6428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1779', '5', '1', '1', '17844', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2024-07-18 17:58:14','0','0');
UPDATE save SET  savecurrentvalue = '10930',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9180.00','1750', '0', '5', 'اضافة فاتورة مبيعات', '17844', '10930', '2024-07-18 17:58:14', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 1750, 1680, 1251
                    , 1616.32, 1251, 1616.32, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1750, sellCostBuyPrice =sellCostBuyPrice+1680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1251, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1616.32
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1251, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1616.32
                            , 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-07-18', 1750, 1680, 1251
                    , 1616.32, 1251, 1616.32, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1750, sellCostBuyPrice =sellCostBuyPrice+1680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1251, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1616.32
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1251, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1616.32
                            , 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, 1750, 1680, 1251
                    , 1616.32, 1251, 1616.32, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1750, netSellCostBuyPrice = netSellCostBuyPrice+1680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1251
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1616.32
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1251
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1616.32
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992d598cc62 and sellbillId = 17844 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:28:15";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:58:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:58:15', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:28:21";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:58:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:58:21', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:28:59";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:58:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:58:59', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992d8dafbeb
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:58:21', '066992d8dafbeb', '1', '0.00', '0', '0', '1', '1665', '1665', '-1665', '0', '5', '2024-07-18 17:58:59', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '4', '0', '', '','','','-1','0','0','0','','0','-1665','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','اضافة فاتورة مردوات مبيعات','6061', '0', '2024-07-18 17:58:59', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '1665', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('475.00', '01786', '6061', '1', '1786', '1', '485.00', '485', '0', '', '2', '0', '1786', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where returnsellbilldetailid = 13054;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1786, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 485, 475, 475, 475
                    , 475, 475, 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+485, returnSellCostBuyPrice = returnSellCostBuyPrice+475, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+475
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+475, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+475
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+475
                            , 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 485, 475, 475, 475
                    , 475, 475, 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+485, returnSellCostBuyPrice = returnSellCostBuyPrice+475, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+475
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+475, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+475
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+475
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '7', storedetaildate = '2024-07-18 17:58:59' WHERE storedetailid = '6420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '5', '1', '0', '6061', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '8.00', '9', '7', '2024-07-18 17:58:59','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('360.00', '01785', '6061', '1', '1785', '2', '370.00', '740', '0', '', '2', '0', '1785', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where returnsellbilldetailid = 13055;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 740, 720, 720, 720
                    , 720, 720, 0, 0, 2)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+740, returnSellCostBuyPrice = returnSellCostBuyPrice+720, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+720
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+720, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+720
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+720
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+2;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 740, 720, 720, 720
                    , 720, 720, 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+740, returnSellCostBuyPrice = returnSellCostBuyPrice+720, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+720
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+720, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+720
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+720
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '7', storedetaildate = '2024-07-18 17:58:59' WHERE storedetailid = '6419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '5', '2', '0', '6061', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '18.00', '20', '7', '2024-07-18 17:58:59','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01781', '6061', '1', '1781', '1', '440.00', '440', '0', '', '2', '0', '1781', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 13056;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1781, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 430, 430, 430
                    , 430, 430, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 430, 430, 430
                    , 430, 430, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2024-07-18 17:58:59' WHERE storedetailid = '6418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '5', '1', '0', '6061', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '14.00', '15', '7', '2024-07-18 17:58:59','0','0');
UPDATE save SET  savecurrentvalue = '9265',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10930.00','1665', '1', '5', 'اضافة فاتورة مردوات مبيعات', '6061', '9265', '2024-07-18 17:58:59', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1665, 1625, 1625, 1625
                    , 1625, 1625, 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+1665, returnSellCostBuyPrice = returnSellCostBuyPrice+1625, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1625
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1625, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1625
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1625
                        , 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1665, 1625, 1625, 1625
                    , 1625, 1625, 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+1665, returnSellCostBuyPrice = returnSellCostBuyPrice+1625, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1625
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1625, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1625
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1625
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -1665, -1625, -1625
                    , -1625, -1625, -1625, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-1665, netSellCostBuyPrice = netSellCostBuyPrice+-1625
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1625
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-1625
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1625
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-1625
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992d8dafbeb and sellbillId = 6061 and returnsellbillId = 6061
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:29:00";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:59:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:59:00', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:29:09";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:59:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:59:09', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:29:31";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:59:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:59:31', '7', 'addAndRetuen', '197.192.204.250', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066992dbd9151f
-- ----------------------------------------------------------------------------------------------------

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-07-18 17:59:09', '066992dbd9151f', '1', '0.00', '0', '0', '1', '360', '360', '360', '0', '5', '2024-07-18 17:59:31', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','360','0','','0','0','360','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','اضافة فاتورة مبيعات','17845', '0', '2024-07-18 17:59:31', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19237;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17845', '1', '1770', '1', '360.00', '360', '0', '', '2', '2024-07-18 17:59:31', '1770', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19237-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52850;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-07-18', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-18', 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 = '21', userid = '7', storedetaildate = '2024-07-18 17:59:31' WHERE storedetailid = '6372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '1', '1', '17845', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22.00', '21', '7', '2024-07-18 17:59:31','0','0');
UPDATE save SET  savecurrentvalue = '9625',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9265.00','360', '0', '5', 'اضافة فاتورة مبيعات', '17845', '9625', '2024-07-18 17:59:31', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 360, 350, 350
                    , 350, 350, 350, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+360, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066992dbd9151f and sellbillId = 17845 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:29:32";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 17:59:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 17:59:32', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:30:04";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:00:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 18:00:04', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:30:13";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:00:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 18:00:13', '7', 'showDetail', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:39:31";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:09:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 18:09:31', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:41:56";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:11:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 18:11:56', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:42:02";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:12:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 18:12:02', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:42:08";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:12:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 18:12:08', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:42:15";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:12:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:12:16', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 14:51:25";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 18:21:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:21:25', '1', 'addsellBill', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:08:53";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:38:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:38:53', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:09:12";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:39:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 18:39:12', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:09:55";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:39:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:39:55', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:10:57";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:40:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:40:57', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:11:20";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:41:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 18:41:20', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:11:30";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:41:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 18:41:31', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:11:54";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:41:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:41:55', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:12:16";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:42:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 18:42:16', '7', '', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:12:53";
UPDATE user SET loginip = "197.192.204.250", lastactivetime = "2024-07-18 18:42:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 18:42:53', '7', 'addsellBill', '197.192.204.250', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:57:42";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 19:27:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 19:27:43', '1', 'add', '156.210.74.201', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6476';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '6', '6', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '6.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6462';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1794', '6', '21', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '21.00', '21', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6461';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1740', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6460';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '6', '21', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '21.00', '21', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6459';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1804', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '9.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '6', '18', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '18.00', '18', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1766', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '6', '18', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '18.00', '18', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6413';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '6', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '15.00', '15', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6412';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6411';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '19.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '9.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '6', '10', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '10.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '6', '7', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '7.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6375';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '6', '7', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '7.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6374';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1769', '6', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '3.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1764', '6', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '4.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('165', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6335';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('167', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '20.00', '19', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6334';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '10.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6332';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6331';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1755', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '15.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1750', '6', '40', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '40.00', '40', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '6', '6', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6230';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '6', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '15.00', '26', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6229';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '19.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6228';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1726', '6', '18', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '18.00', '18', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6227';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1725', '6', '6', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '7.00', '13', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '6', '7', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '9.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6225';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1724', '6', '17', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '17.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6201';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1297', '6', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6200';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1673', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '1.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6199';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1656', '6', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6198';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1603', '6', '0', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '0.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6197';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1637', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6171';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '6', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6170';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '6', '14', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '14.00', '14', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6153';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1600', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6152';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1523', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6140';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1690', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '42', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6139';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1694', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '41.00', '42', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6138';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1693', '6', '9', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '9.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6137';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1692', '6', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '28.00', '31', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6136';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1691', '6', '20', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '20.00', '20', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6096';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1677', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6095';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '6', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '5.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6094';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1680', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6093';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1679', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '4.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6086';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1675', '6', '7', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6080';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1636', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6052';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1660', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '5.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '6', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '5.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6050';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1662', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '8.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6049';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1665', '6', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '24.00', '32', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6048';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '6', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '5.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6047';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1452', '6', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '6.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6035';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1659', '6', '6', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6002';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1646', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '8.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1645', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5985';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1644', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '11.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5984';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1641', '6', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '8.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5983';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5982';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1640', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '8.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5981';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1639', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '4.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5962';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1638', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '3.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5930';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1633', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5926';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1631', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '2.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5921';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5912';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1629', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5911';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1628', '6', '14', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '15.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5910';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1627', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '21.00', '20', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5909';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1626', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '19.00', '20', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5907';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1624', '6', '9', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '9', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '110', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5906';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1623', '6', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '95.00', '110', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5905';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1622', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '14.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5885';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1617', '6', '18', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '38.00', '20', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5809';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1590', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '11.00', '8', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5792';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('302', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '2.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5666';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1569', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5665';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1566', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '11.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5663';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1541', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5661';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1552', '6', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '11.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5660';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1553', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '7.00', '6', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5659';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1551', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '9.00', '11', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5658';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1549', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5657';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1550', '6', '10', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '10.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5650';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1587', '6', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '12.00', '12', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5647';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1526', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5644';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1522', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '19.00', '20', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5637';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5636';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1580', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '36.00', '35', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5635';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '18.00', '17', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1576', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '18.00', '16', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5633';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1575', '6', '21', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '21.00', '21', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '38', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5631';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1585', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '40.00', '38', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5629';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '6', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '36.00', '30', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '48', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5628';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1582', '6', '17', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '31.00', '48', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5627';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1584', '6', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '35.00', '31', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5626';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1579', '6', '10', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '10.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5539';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1507', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5529';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1512', '6', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '4.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5519';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1508', '6', '23', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '23.00', '23', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5491';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1499', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1496', '6', '4', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '4.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1477', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1476', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5411';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1473', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '3.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1472', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '2.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1471', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5389';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1466', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1455', '6', '6', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '6.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5221';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1414', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5184';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1402', '6', '13', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '13.00', '13', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4623';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('654', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1160', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '4', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1162', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1161', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1134', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '3307';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('964', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '4.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '3127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('949', '6', '20', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '20.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '3068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('942', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '3067';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('945', '6', '3', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '4.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '3063';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('944', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '2.00', '3', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '2231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('283', '6', '18', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '18.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1492';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '6', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '1.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('517', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '5.00', '7', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1050';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('516', '6', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '2.00', '2', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1049';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1048';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '6', '3', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '4.00', '1', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '25', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '1014';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('412', '6', '25', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية لم يتغير', 'inventoryController.php', '25.00', '25', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '960';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('478', '6', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '2.00', '0', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '947';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('90', '6', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-07-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 15:57:58";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 19:27:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 19:27:58', '1', 'show', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:09:24";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 19:39:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 19:39:24', '1', 'add', '156.210.74.201', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '5417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1479', '6', '5', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '5', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1324', '6', '10', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '10', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4022';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('621', '6', '28', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '28', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '4017';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('100', '6', '19', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '19', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '2228';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('669', '6', '13', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '13', '1', '2024-07-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:09:26";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 19:39:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-07-18 19:39:26', '1', 'show', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:54:54";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:55:11";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:25:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 20:25:11', '7', '', '197.192.234.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-07-18 16:55: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-07-18 16:55:28";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:25:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 20:25:28', '7', '', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:55:49";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:25:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 20:25:49', '7', 'addsellBill', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:55:57";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:25:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:25:57', '7', '', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:56:25";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:26:25", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:26:25', '7', 'add', '197.192.234.236', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'مرتب موفق', '', '1000', '2024-07-18', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '8625',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9625.00','1000', '1', '5', 'إضافة مصروف', '5219', '8625', '2024-07-18 20:26:25', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1000', '1000', '2024-07-18', '7', '0', '0', '2024-07-18 20:26:25','اضافة اسم مصروف( مرتب موفق )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10693', '145', '1000', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '546840', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10693', '139', '1000', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3311418', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'مرتب موفق', expensesdetails = '', expensesValue = '1000.00', expensesdate = '2024-07-18', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10693', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5219';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:56:27";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:26:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:26:28', '7', 'sucess', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:56:30";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:26:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:26:30', '7', 'show', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:56:35";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:26:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 20:26:36', '7', '', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:56:40";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:26:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 20:26:40', '7', 'showDetail', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 16:57:11";
UPDATE user SET loginip = "197.192.234.236", lastactivetime = "2024-07-18 20:27:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 20:27:11', '7', 'addsellBill', '197.192.234.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE userid = 3;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:08:51";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:38:52", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 20:38:52', '8', '', '197.63.212.7', '', '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-07-18 17:08:52";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:08:54";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:38:54", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 20:38:54', '8', 'addsellBill', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:15";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:15", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 20:40:15', '8', 'addAndRetuen', '197.63.212.7', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06699532f269e3
-- ----------------------------------------------------------------------------------------------------

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-07-18 20:38:55', '06699532f269e3', '1', '0.00', '0', '0', '1', '2160', '2160', '2160', '0', '6', '2024-07-18 20:40:15', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','2160','0','','0','0','2160','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17846', '0', '2024-07-18 20:40:15', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2160', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19205;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19491;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17846', '1', '1577', '4', '450', '1800', '0', '', '0', '2024-07-18 20:40:15', '1577', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','19205-2,19491-2,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52851;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-18', 1800, 1800, 1800
                    , 1800, 1800, 1800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 4, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1800, sellCostBuyPrice =sellCostBuyPrice+1800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1800
                            , 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+4
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-18', 1800, 1800, 1800
                    , 1800, 1800, 1800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1800, sellCostBuyPrice =sellCostBuyPrice+1800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '8', storedetaildate = '2024-07-18 20:40:15' WHERE storedetailid = '5638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '6', '4', '1', '17846', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '16', '8', '2024-07-18 20:40:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19215;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('360','01785', '17846', '1', '1785', '1', '360', '360', '0', '', '0', '2024-07-18 20:40:15', '1785', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','19215-1,');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 52852;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-07-18', 360, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-18', 360, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '8', storedetaildate = '2024-07-18 20:40:15' WHERE storedetailid = '6413';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '6', '1', '1', '17846', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '8', '2024-07-18 20:40:15','0','0');
UPDATE save SET  savecurrentvalue = '14335',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('12175.00','2160', '0', '6', 'اضافة فاتورة مبيعات', '17846', '14335', '2024-07-18 20:40:15', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 2160, 2160, 2160
                    , 2160, 2160, 2160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2160, sellCostBuyPrice =sellCostBuyPrice+2160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2160
                            , 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-07-18', 2160, 2160, 2160
                    , 2160, 2160, 2160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2160, sellCostBuyPrice =sellCostBuyPrice+2160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2160
                            , 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, 2160, 2160, 2160
                    , 2160, 2160, 2160, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2160, netSellCostBuyPrice = netSellCostBuyPrice+2160
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2160
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2160
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2160
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2160
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06699532f269e3 and sellbillId = 17846 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:16";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:16", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 20:40:16', '8', 'addsellBill', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:19";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:19", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:19', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:32";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:32", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:32', '8', 'add', '197.63.212.7', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جهاد', '', '700', '2024-07-18', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '13635',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('14335.00','700', '1', '6', 'إضافة مصروف', '5220', '13635', '2024-07-18 20:40:32', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '700', '700', '2024-07-18', '8', '0', '0', '2024-07-18 20:40:32','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10694', '160', '700', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4573565', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10694', '140', '700', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2074142', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جهاد', expensesdetails = '', expensesValue = '700.00', expensesdate = '2024-07-18', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10694', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5220';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:33";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:33", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:33', '8', 'sucess', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:35";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:35", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:35', '8', 'show', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:37";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:37", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:37', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:10:51";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:40:51", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:40:51', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:11:04";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:41:04", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:41:04', '8', 'add', '197.63.212.7', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'فطار', '', '20', '2024-07-18', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '13615',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('13635.00','20', '1', '6', 'إضافة مصروف', '5221', '13615', '2024-07-18 20:41:04', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-07-18', '8', '0', '0', '2024-07-18 20:41:04','اضافة اسم مصروف( فطار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10695', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4573585', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10695', '140', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2074162', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'فطار', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-07-18', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10695', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5221';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:11:05";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:41:05", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:41:05', '8', 'sucess', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:11:07";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:41:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:41:07', '8', 'show', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:11:11";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:41:11", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 20:41:11', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:12:05";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:42:05", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:42:05', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:13:33";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:43:33", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:43:33', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:14:03";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:44:03", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:44:03', '8', 'add', '197.63.212.7', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جهاد', '', '500', '2024-07-18', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '13115',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('13615.00','500', '1', '6', 'إضافة مصروف', '5222', '13115', '2024-07-18 20:44:03', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '500', '500', '2024-07-18', '8', '0', '0', '2024-07-18 20:44:03','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10696', '160', '500', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4574085', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10696', '140', '500', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2074662', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جهاد', expensesdetails = '', expensesValue = '500.00', expensesdate = '2024-07-18', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10696', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5222';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:14:04";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:44:04", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:44:04', '8', 'sucess', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:14:06";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:44:06", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 20:44:06', '8', 'show', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:14:13";
UPDATE user SET loginip = "197.63.212.7", lastactivetime = "2024-07-18 20:44:13", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 20:44:13', '8', '', '197.63.212.7', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:27:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:27:34";
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-07-18 17:27:45";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 20:57:45", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 20:57:45', '3', '', '197.32.190.24', '', '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-07-18 17:27:45";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:40:16";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:10:16", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:10:16', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:45:41";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:15:41", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:15:41', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995a88ab90f
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:10:16', '066995a88ab90f', '1', '0.00', '0', '0', '1', '3630', '3630', '3630', '0', '8', '2024-07-18 21:15:41', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '9' ,'0','','','','','-1','0','0','0','0','0','3630','0','','0','0','3630','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17847', '0', '2024-07-18 21:15:41', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3630', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19523;
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 ('180','00146', '17847', '1', '146', '1', '200', '200', '0', '', '1', '2024-07-18 21:15:41', '146', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19523-1,');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 272.50, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 272.50
                where sellbilldetailid = 52853;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (146, '2024-07-18', 200, 370, 180
                    , 272.5, 180, 272.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 200, 370, 180
                    , 272.5, 180, 272.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '3997';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('146', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17847', '1', '1795', '1', '460', '460', '0', '', '1', '2024-07-18 21:15:41', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52854;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 460, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 460, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19535;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17847', '1', '1770', '1', '430', '430', '0', '', '1', '2024-07-18 21:15:41', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19535-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52855;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19441;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('370','01583', '17847', '1', '1583', '1', '420', '420', '0', '', '1', '2024-07-18 21:15:41', '1583', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19441-1,');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 52856;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1583, '2024-07-18', 420, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 420, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6436';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19417;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('310','01774', '17847', '2', '1774', '1', '390', '390', '0', '', '1', '2024-07-18 21:15:41', '1774', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19417-1,');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
                where sellbilldetailid = 52857;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1774, '2024-07-18', 390, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 390, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6382';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1774', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19535;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17847', '1', '1770', '1', '430', '430', '0', '', '1', '2024-07-18 21:15:41', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19535-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52858;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19447;
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','01803', '17847', '1', '1803', '1', '430', '430', '0', '', '1', '2024-07-18 21:15:41', '1803', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19447-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52859;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1803, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '3', storedetaildate = '2024-07-18 21:15:41' WHERE storedetailid = '6454';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1803', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '3', '2024-07-18 21:15:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17847', '1', '1795', '1', '460', '460', '0', '', '1', '2024-07-18 21:15:42', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52860;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 460, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 460, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '3', storedetaildate = '2024-07-18 21:15:42' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '3', '2024-07-18 21:15:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19521;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('330','01807', '17847', '1', '1807', '1', '410', '410', '0', '', '1', '2024-07-18 21:15:42', '1807', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19521-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 52861;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1807, '2024-07-18', 410, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 410, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '3', storedetaildate = '2024-07-18 21:15:42' WHERE storedetailid = '6469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '8', '1', '1', '17847', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '3', '2024-07-18 21:15:42','0','0');
UPDATE save SET  savecurrentvalue = '30460',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('26830.00','3630', '0', '8', 'اضافة فاتورة مبيعات', '17847', '30460', '2024-07-18 21:15:42', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 3630, 3190, 3190
                    , 3187.5, 3190, 3187.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3630, sellCostBuyPrice =sellCostBuyPrice+3190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3187.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3187.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 3630, 3190, 3190
                    , 3187.5, 3190, 3187.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3630, sellCostBuyPrice =sellCostBuyPrice+3190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3187.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3187.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 3630, 3190, 3190
                    , 3187.5, 3190, 3187.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3630, netSellCostBuyPrice = netSellCostBuyPrice+3190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3187.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3187.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995a88ab90f and sellbillId = 17847 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:45:42";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:15:42", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:15:42', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:47:35";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:17:35", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:17:35', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995bce9b304
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:15:42', '066995bce9b304', '1', '0.00', '0', '50', '1', '1170', '1120', '1120', '0', '8', '2024-07-18 21:17:35', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1120','0','','0','0','1120','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17848', '0', '2024-07-18 21:17:35', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1120', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17848', '1', '1795', '1', '390.00', '390', '0', '', '2', '2024-07-18 21:17:35', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52862;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '3', storedetaildate = '2024-07-18 21:17:35' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17848', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '3', '2024-07-18 21:17:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17848', '1', '1795', '1', '390.00', '390', '0', '', '2', '2024-07-18 21:17:35', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52863;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '3', storedetaildate = '2024-07-18 21:17:35' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17848', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12.00', '11', '3', '2024-07-18 21:17:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17848', '1', '1795', '1', '390.00', '390', '0', '', '2', '2024-07-18 21:17:35', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52864;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 373.33333333333, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+373.33333333333, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '3', storedetaildate = '2024-07-18 21:17:35' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17848', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '3', '2024-07-18 21:17:35','0','0');
UPDATE save SET  savecurrentvalue = '31580',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('30460.00','1120', '0', '8', 'اضافة فاتورة مبيعات', '17848', '31580', '2024-07-18 21:17:35', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 1120, 1140, 1425
                    , 1282.5, 1425, 1282.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1120, sellCostBuyPrice =sellCostBuyPrice+1140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1282.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1282.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 1120, 1140, 1425
                    , 1282.5, 1425, 1282.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1120, sellCostBuyPrice =sellCostBuyPrice+1140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1282.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1282.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1120, 1140, 1425
                    , 1282.5, 1425, 1282.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1120, netSellCostBuyPrice = netSellCostBuyPrice+1140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1425
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1282.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1425
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1282.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995bce9b304 and sellbillId = 17848 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:47:35";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:17:35", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:17:35', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:47:42";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:17:42", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:17:42', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:48:13";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:18:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:18:13', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995c46d0a18
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:17:42', '066995c46d0a18', '1', '0.00', '0', '0', '1', '440', '440', '-440', '0', '8', '2024-07-18 21:18:13', '', '3', '0', 'نقدي','8', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-440','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','6062', '0', '2024-07-18 21:18:13', '3', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '440', '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 ('360.00', '01575', '6062', '1', '1575', '1', '440', '440', '0', '', '1', '0', '1575', '0.00', '0','8','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where returnsellbilldetailid = 13057;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1575, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 360
                    , 360, 360, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , 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 (8, '2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 360
                    , 360, 360, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '18', userid = '3', storedetaildate = '2024-07-18 21:18:13' WHERE storedetailid = '5767';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1575', '8', '1', '0', '6062', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '17.00', '18', '3', '2024-07-18 21:18:13','0','0');
UPDATE save SET  savecurrentvalue = '31140',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('31580.00','440', '1', '8', 'اضافة فاتورة مردوات مبيعات', '6062', '31140', '2024-07-18 21:18:13', '3',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 360
                    , 360, 360, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , 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-07-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 360
                    , 360, 360, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+440, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -440, -360, -360
                    , -360, -360, -360, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-440, netSellCostBuyPrice = netSellCostBuyPrice+-360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995c46d0a18 and sellbillId = 6062 and returnsellbillId = 6062
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:48:14";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:18:14", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:18:14', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:48:18";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:18:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 21:18:18', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:50:13";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:20:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:20:13', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:52:14";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:22:14", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:22:14', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995cdddad8d
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:20:13', '066995cdddad8d', '1', '0.00', '0', '40', '1', '1850', '1810', '1810', '0', '8', '2024-07-18 21:22:14', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1810','0','','0','0','1810','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17849', '0', '2024-07-18 21:22:14', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1810', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19537;
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','01795', '17849', '1', '1795', '1', '460', '460', '0', '', '1', '2024-07-18 21:22:14', '1795', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19537-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 427.50, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 427.50
                where sellbilldetailid = 52865;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1795, '2024-07-18', 450.05405405405, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450.05405405405, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 450.05405405405, 380, 475
                    , 427.5, 475, 427.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450.05405405405, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+427.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+427.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '3', storedetaildate = '2024-07-18 21:22:14' WHERE storedetailid = '6473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '1', '1', '17849', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '3', '2024-07-18 21:22:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19535;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17849', '1', '1770', '1', '430', '430', '0', '', '1', '2024-07-18 21:22:14', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19535-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52866;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-07-18', 420.7027027027, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420.7027027027, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 420.7027027027, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420.7027027027, 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 = '14', userid = '3', storedetaildate = '2024-07-18 21:22:14' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '1', '1', '17849', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '3', '2024-07-18 21:22:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17643;
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 ('500','01639', '17849', '1', '1639', '1', '530', '530', '0', '', '1', '2024-07-18 21:22:14', '1639', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17643-1,');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 465.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 465.00
                where sellbilldetailid = 52867;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1639, '2024-07-18', 518.54054054054, 450, 500
                    , 465, 500, 465, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+518.54054054054, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 518.54054054054, 450, 500
                    , 465, 500, 465, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+518.54054054054, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '3', storedetaildate = '2024-07-18 21:22:14' WHERE storedetailid = '5969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1639', '8', '1', '1', '17849', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '3', '2024-07-18 21:22:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19511;
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','01804', '17849', '1', '1804', '1', '430', '430', '0', '', '1', '2024-07-18 21:22:14', '1804', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19511-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52868;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1804, '2024-07-18', 420.7027027027, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420.7027027027, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 420.7027027027, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420.7027027027, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '3', storedetaildate = '2024-07-18 21:22:14' WHERE storedetailid = '6464';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1804', '8', '1', '1', '17849', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '3', '2024-07-18 21:22:14','0','0');
UPDATE save SET  savecurrentvalue = '32950',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('31140.00','1810', '0', '8', 'اضافة فاتورة مبيعات', '17849', '32950', '2024-07-18 21:22:14', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 1810, 1530, 1675
                    , 1592.5, 1675, 1592.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1810, sellCostBuyPrice =sellCostBuyPrice+1530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1592.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1592.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 1810, 1530, 1675
                    , 1592.5, 1675, 1592.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1810, sellCostBuyPrice =sellCostBuyPrice+1530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1592.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1592.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1810, 1530, 1675
                    , 1592.5, 1675, 1592.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1810, netSellCostBuyPrice = netSellCostBuyPrice+1530
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1675
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1592.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1675
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1592.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995cdddad8d and sellbillId = 17849 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:52:15";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:22:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:22:15', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:00";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:26:00', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995d5788f9e
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:22:15', '066995d5788f9e', '1', '0.00', '0', '0', '1', '460', '460', '460', '0', '8', '2024-07-18 21:26:00', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','460','0','','0','0','460','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17850', '0', '2024-07-18 21:26:00', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19455;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17850', '1', '1577', '1', '460.00', '460', '0', '', '2', '2024-07-18 21:26:00', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','19455-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52869;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '25', userid = '3', storedetaildate = '2024-07-18 21:26:00' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '17850', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26.00', '25', '3', '2024-07-18 21:26:00','0','0');
UPDATE save SET  savecurrentvalue = '33410',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('32950.00','460', '0', '8', 'اضافة فاتورة مبيعات', '17850', '33410', '2024-07-18 21:26:00', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 460, 450, 450
                    , 450, 450, 450, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995d5788f9e and sellbillId = 17850 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:00";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:26:00', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:17";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:26:18', '3', 'addAndRetuen', '197.32.190.24', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066995e39213a4
-- ----------------------------------------------------------------------------------------------------

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-07-18 21:26:01', '066995e39213a4', '1', '0.00', '0', '0', '1', '840', '840', '840', '0', '8', '2024-07-18 21:26:18', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','840','0','','0','0','840','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17851', '0', '2024-07-18 21:26:18', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '840', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19085;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('400','01776', '17851', '2', '1776', '2', '420.00', '840', '0', '', '0', '2024-07-18 21:26:18', '1776', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','19085-2,');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where sellbilldetailid = 52870;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1776, '2024-07-18', 840, 800, 800
                    , 800, 800, 800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-18', 840, 800, 800
                    , 800, 800, 800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '3', storedetaildate = '2024-07-18 21:26:18' WHERE storedetailid = '6385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1776', '8', '2', '1', '17851', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '6', '3', '2024-07-18 21:26:18','0','0');
UPDATE save SET  savecurrentvalue = '34250',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('33410.00','840', '0', '8', 'اضافة فاتورة مبيعات', '17851', '34250', '2024-07-18 21:26:18', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 840, 800, 800
                    , 800, 800, 800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , 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-07-18', 840, 800, 800
                    , 800, 800, 800, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+800
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+800
                            , 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, 840, 800, 800
                    , 800, 800, 800, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+840, netSellCostBuyPrice = netSellCostBuyPrice+800
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+800
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+800
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+800
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+800
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066995e39213a4 and sellbillId = 17851 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:18";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:26:18', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:22";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:22", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 21:26:22', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:56:25";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:26:25", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:26:25', '3', 'showDetail', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:57:13";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:27:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 21:27:13', '3', 'addsellBill', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:57:15";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:27:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 21:27:15', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:58:47";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:28:47", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:28:48', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:58:58";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:28:58", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:28:58', '3', 'add', '197.32.190.24', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'القبض بدون النسبه', '', '1100', '2024-07-18', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '33150',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('34250.00','1100', '1', '8', 'إضافة مصروف', '5223', '33150', '2024-07-18 21:28:58', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1100', '1100', '2024-07-18', '3', '0', '0', '2024-07-18 21:28:58','اضافة اسم مصروف( القبض بدون النسبه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10697', '160', '1100', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4575185', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10697', '142', '1100', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2913486', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'القبض بدون النسبه', expensesdetails = '', expensesValue = '1100.00', expensesdate = '2024-07-18', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10697', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5223';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:58:59";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:28:59", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:28:59', '3', 'sucess', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:59:01";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:29:01", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:29:01', '3', 'show', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 17:59:01";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:29:01", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 21:29:01', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:25:00";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:55:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:55:01', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:25:48";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:55:48", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:55:48', '3', 'add', '197.32.190.24', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'تاكسي', '', '100', '2024-07-18', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '33050',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('33150.00','100', '1', '8', 'إضافة مصروف', '5224', '33050', '2024-07-18 21:55:48', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2024-07-18', '3', '0', '0', '2024-07-18 21:55:48','اضافة اسم مصروف( تاكسي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10698', '160', '100', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4575285', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10698', '142', '100', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2913586', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'تاكسي', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-07-18', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10698', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5224';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:25:49";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:55:49", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:55:49', '3', 'sucess', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:25:50";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:55:50", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-18 21:55:50', '3', 'show', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:25:52";
UPDATE user SET loginip = "197.32.190.24", lastactivetime = "2024-07-18 21:55:52", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 21:55:52', '3', '', '197.32.190.24', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:58:37";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:58:51";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:28:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 22:28:51', '1', '', '156.210.74.201', '', '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-07-18 18:58: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-07-18 18:59:06";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:29:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:29:06', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:59:07";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:29:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:29:07', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:59:36";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:29:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:29:36', '1', 'add', '156.210.74.201', '', '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(2167,1,7,1780,27,'2024-07-18',1,0, '' ,0,0,0,0,0,'2024-07-18 22:29:36',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-27', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6399';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1780, 0, 0
                    , 250.00, -27, 0, 0, 1, '2024-07-18 22:29:36')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 22:29:36' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2024-07-18*250.00," WHERE transferproductid = 8991;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '1', '27', '1', '8991', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-27', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '42', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6400';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 7, 1780, 0, 0
                    , 250.00, 27, 0, 0, 1, '2024-07-18 22:29:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 22:29:36' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '7', '27', '0', '8991', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '15.00', '42', '1', '2024-07-18','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 18:59:37";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:29:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:29:37', '1', 'editshow', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:00:45";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:30:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:30:45', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:01:03";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:31:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:31:03', '1', 'add', '156.210.74.201', '', '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(2168,1,8,1780,27,'2024-07-18',1,0, '' ,0,0,0,0,0,'2024-07-18 22:31:03',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-54', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6399';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 1, 1780, 0, 0
                    , 250.00, -27, 0, 0, 1, '2024-07-18 22:31:03')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 22:31:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2024-07-18*250.00," WHERE transferproductid = 8992;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '1', '27', '1', '8992', 'تحويل منتجات من المخزن', 'storemovementController.php', '-27.00', '-54', '1', '2024-07-18','0','0');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-07-18' WHERE storedetailid = '6401';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-18', 8, 1780, 0, 0
                    , 250.00, 27, 0, 0, 1, '2024-07-18 22:31:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-18 22:31:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '27', '0', '8992', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '13.00', '40', '1', '2024-07-18','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:01:04";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:31:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-18 22:31:04', '1', 'editshow', '156.210.74.201', '', 'DESKTOP');
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-07-18 19:02:40";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:32:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 22:32:40', '4', '', '156.210.74.201', '', '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-07-18 19:02:40";
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-07-18 19:02:59";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:32:59", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 22:32:59', '4', 'addsellBill', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:04:19";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:34:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 22:34:19', '4', 'addAndRetuen', '156.210.74.201', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066996debc4e60
-- ----------------------------------------------------------------------------------------------------

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-07-18 22:32:59', '066996debc4e60', '1', '0.00', '0', '10', '1', '410', '400', '400', '0', '7', '2024-07-18 22:34:19', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','17852', '0', '2024-07-18 22:34:19', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19513;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('330','01807', '17852', '1', '1807', '1', '410.00', '410', '0', '', '1', '2024-07-18 22:34:19', '1807', '0.00', '0', '7','0','','','0','0','0','0','0','0','1','0','','19513-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 52871;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1807, '2024-07-18', 400, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 400, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '4', storedetaildate = '2024-07-18 22:34:19' WHERE storedetailid = '6468';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '7', '1', '1', '17852', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '4', '2024-07-18 22:34:19','0','0');
UPDATE save SET  savecurrentvalue = '8855',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8455.00','400', '0', '7', 'اضافة فاتورة مبيعات', '17852', '8855', '2024-07-18 22:34:19', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 400, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 400, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 400, 330, 330
                    , 330, 330, 330, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+330
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066996debc4e60 and sellbillId = 17852 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:04:19";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:34:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 22:34:19', '4', 'addsellBill', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:07:22";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:37:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 22:37:22', '4', 'addAndRetuen', '156.210.74.201', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066996e3c0605a
-- ----------------------------------------------------------------------------------------------------

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-07-14  10:30:20', '066996e3c0605a', '1', '0.00', '0', '0', '1', '830', '830', '830', '0', '7', '2024-07-18 22:37:23', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','830','0','','0','0','830','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','اضافة فاتورة مبيعات','17853', '0', '2024-07-18 22:37:23', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '830', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19195;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17853', '1', '1577', '1', '460.00', '460', '0', '', '2', '2024-07-18 22:37:23', '1577', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','19195-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52872;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '4', storedetaildate = '2024-07-18 22:37:23' WHERE storedetailid = '6160';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '7', '1', '1', '17853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '4', '2024-07-18 22:37:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19513;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('330','01807', '17853', '1', '1807', '1', '370', '370', '0', '', '2', '2024-07-18 22:37:23', '1807', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','19513-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 52873;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1807, '2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-07-18', 370, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '4', storedetaildate = '2024-07-18 22:37:23' WHERE storedetailid = '6468';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '7', '1', '1', '17853', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '4', '2024-07-18 22:37:23','0','0');
UPDATE save SET  savecurrentvalue = '9685',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8855.00','830', '0', '7', 'اضافة فاتورة مبيعات', '17853', '9685', '2024-07-18 22:37:23', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-18', 830, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-18', 830, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 830, 780, 780
                    , 780, 780, 780, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+830, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+780
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+780
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066996e3c0605a and sellbillId = 17853 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:07:23";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:37:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-18 22:37:23', '4', 'addsellBill', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:08:14";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:38:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:38:15', '4', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:08:34";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:38:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:38:34', '4', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:09:21";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:39:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:39:21', '4', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:09:36";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:39:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 22:39:36', '4', '', '156.210.74.201', '', '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-07-18 19:09: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 userid = 4;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:09:57";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:39:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-18 22:39:57', '1', '', '156.210.74.201', '', '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-07-18 19:09: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-07-18 19:10:01";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:40:01', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:10:09";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:40:09', '1', 'show', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:10:42";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-18 22:40:42', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:10:52";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-18 22:40:52', '1', 'add', '156.210.74.201', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '7', '-1', '0', '9685.00', '5', '9690', '', '0', '2024-07-18 22:40:52', '1', 'settlementsaveController.php');
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('-1', '', '5', '1', ' خصم معالجة عجز  / ', '599', '-5', '2024-07-18', '1', 'supplierPayedDeptController.php', '', '0','7', '0','1','1','5','1');
UPDATE supplier SET  suppliercurrentDebt = '-5', userid = '1', supplierdate = '2024-07-18'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '5.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '599', supplierdebtchangeafter = '-5.00', supplierdebtchangedate = '2024-07-18 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '7',currencyId='1',conversionFactor='1',payedInCurrency='5',saveConversionFactor='1' WHERE supplierdebtchangeid = '974';
UPDATE save SET  savecurrentvalue = '9690',  userid = '1' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9685.00','5', '0', '7', 'تسوية خزنة بالإضافة', '-1', '9690', '2024-07-18 22:40:52', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '29727' WHERE savedailyid = '29727';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5', '5', '2024-07-18', '1', '0', '0', '2024-07-18 22:40:53','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10699', '141', '5', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2204337', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10699', '27', '5', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-136310', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:10:53";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-18 22:40:53', '1', 'sucess', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:10:55";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:40:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-18 22:40:55', '1', 'show', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:11:16";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:41:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:41:16', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:11:26";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 22:41:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-18 22:41:26', '1', 'show', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:35:47";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:05:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:05:47', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:37:23";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:07:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:07:23', '1', 'add', '156.210.74.201', '', '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 =26442
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(400,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '87845' , clientdate = '2024-07-18 23:07:23', userid = '1' WHERE clientid = '400';
UPDATE client SET  inUse = 0 where clientid = 400;
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 ('400','97845.00','10000','1','ايصال تحصيل (( قبض من عميل ))','26442', '87845', '2024-07-18 23:05:47', '1', 'clientPayedDeptController.php', '   ليد الشيخ عبد اللطيف', '10000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '577185',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('567185.00','10000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '26442', '577185', '2024-07-18 23:07:23', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '10000', '10000', '2024-07-18', '1', '0', '0', '2024-07-18 23:07:23','اضافة ايصال سداد للعميل سنتر سامح جمعه','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10700', '54', '10000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '384879', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10700', '471', '10000', '','0');
UPDATE accountstree SET name = 'سنتر سامح جمعه', customName = 'سنتر سامح جمعه', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-11355', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '471';
UPDATE clientdebtchange SET clientid = '400', clientdebtchangebefore = '97845.00', clientdebtchangeamount = '10000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '26442', clientdebtchangeafter = '87845.00', clientdebtchangedate = '2024-07-18 23:05:47', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ليد الشيخ عبد اللطيف', totalOperationCost = '10000.00',discount='', reciptid=null, dailyentryid = '10700',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '26442';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:37:24";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:07:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:07:24', '1', 'editprint2', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:44:08";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:14:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:14:08', '1', '', '156.210.74.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:55:17";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:25:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:25:17', '1', 'add', '156.210.74.201', '', '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 =26443
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(413,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '33375' , clientdate = '2024-07-18 23:25:17', userid = '1' WHERE clientid = '413';
UPDATE client SET  inUse = 0 where clientid = 413;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','38375.00','5000','1','ايصال تحصيل (( قبض من عميل ))','26443', '33375', '2024-07-18 23:14:08', '1', 'clientPayedDeptController.php', '   ليد الشيخ عبد اللطيف', '5000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '582185',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('577185.00','5000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '26443', '582185', '2024-07-18 23:25:17', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000', '5000', '2024-07-18', '1', '0', '0', '2024-07-18 23:25:17','اضافة ايصال سداد للعميل سنتر الفيروز','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10701', '54', '5000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '389879', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10701', '483', '5000', '','0');
UPDATE accountstree SET name = 'سنتر الفيروز', customName = 'سنتر الفيروز', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-05', itemtype2 = '1', theValue = '-20800', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '483';
UPDATE clientdebtchange SET clientid = '413', clientdebtchangebefore = '38375.00', clientdebtchangeamount = '5000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '26443', clientdebtchangeafter = '33375.00', clientdebtchangedate = '2024-07-18 23:14:08', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ليد الشيخ عبد اللطيف', totalOperationCost = '5000.00',discount='', reciptid=null, dailyentryid = '10701',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '26443';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-18 19:55:18";
UPDATE user SET loginip = "156.210.74.201", lastactivetime = "2024-07-18 23:25:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-18 23:25:18', '1', 'editprint2', '156.210.74.201', '', 'DESKTOP');
