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 < "2022-08-20 05:17:54";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 08:47:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 08:47:54', '4', '', '41.233.78.177', '', '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 = '2022-08-20',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 05:17:55";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 05:17:56";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 08:47:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 08:47:56', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:06:30";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:36:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:36:30', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:02";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:02", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:37:02', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300839d01a70
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 08:47:57', '06300839d01a70', '1', '0.00', '0', '0', '1', '350', '350', '350', '0', '7', '2022-08-20 09:37:03', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','350','0','','0','0','350','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','اضافة فاتورة مبيعات','7797', '0', '2022-08-20 09:37:03', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '350', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 7610;
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 ('175','01061', '7797', '1', '1061', '2', '175', '350', '0', '', '0', '2022-08-20 09:37:03', '1061', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','7610-2,');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
                where sellbilldetailid = 23405;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1061, '2022-08-20', 350, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 350, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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 = '3', userid = '4', storedetaildate = '2022-08-20 09:37:03' WHERE storedetailid = '3721';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1061', '7', '2', '1', '7797', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '3', '4', '2022-08-20 09:37:03','0','0');
UPDATE save SET  savecurrentvalue = '550',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('200.00','350', '0', '7', 'اضافة فاتورة مبيعات', '7797', '550', '2022-08-20 09:37:03', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 350, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, '2022-08-20', 350, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, 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, 350, 350, 350
                    , 350, 350, 350, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+350, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300839d01a70 and sellbillId = 7797 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:37:03', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:07";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:37:07', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063008efe53190
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 09:36:30', '063008efe53190', '1', '0.00', '0', '0', '1', '230', '230', '-230', '0', '7', '2022-08-20 09:37:07', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-230','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','اضافة فاتورة مردوات مبيعات','2788', '0', '2022-08-20 09:37:07', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '230', '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 ('230.00', '01113', '2788', '1', '1113', '1', '230', '230', '0', '', '0', '0', '1113', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
                where returnsellbilldetailid = 6071;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1113, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 230, 230, 230
                    , 230, 230, 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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 230, 230, 230
                    , 230, 230, 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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '1', userid = '4', storedetaildate = '2022-08-20 09:37:07' WHERE storedetailid = '4051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1113', '7', '1', '0', '2788', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '1', '4', '2022-08-20 09:37:07','0','0');
UPDATE save SET  savecurrentvalue = '320',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('550.00','230', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2788', '320', '2022-08-20 09:37:07', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 230, 230, 230
                    , 230, 230, 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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 230, 230, 230
                    , 230, 230, 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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -230, -230, -230
                    , -230, -230, -230, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-230, netSellCostBuyPrice = netSellCostBuyPrice+-230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063008efe53190 and sellbillId = 2788 and returnsellbillId = 2788
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:07";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:37:07', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:08";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 09:37:08', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 09:37:10', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:15";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 09:37:15', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:17";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:17", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-08-20 09:37:17', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:07:22";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 09:37:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 09:37:22', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:33:15";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:03:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:03:15', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:34:48";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:04:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:04:48', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063009543725eb
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:03:15', '063009543725eb', '1', '0.00', '0', '0', '1', '220', '220', '220', '0', '7', '2022-08-20 10:04:48', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','220','0','','0','0','220','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','7798', '0', '2022-08-20 10:04:48', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 3050;
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 ('140','00641', '7798', '1', '641', '2', '110', '220', '0', '', '0', '2022-08-20 10:04:48', '641', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','3050-2,');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 125.00
                where sellbilldetailid = 23406;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (641, '2022-08-20', 220, 220, 280
                    , 250, 280, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 220, 220, 280
                    , 250, 280, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '65', userid = '4', storedetaildate = '2022-08-20 10:04:48' WHERE storedetailid = '2068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('641', '7', '2', '1', '7798', 'اضافة فاتورة مبيعات', 'sellbillController.php', '67.00', '65', '4', '2022-08-20 10:04:48','0','0');
UPDATE save SET  savecurrentvalue = '540',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('320.00','220', '0', '7', 'اضافة فاتورة مبيعات', '7798', '540', '2022-08-20 10:04:48', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 220, 220, 280
                    , 250, 280, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 220, 220, 280
                    , 250, 280, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 220, 220, 280
                    , 250, 280, 250, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, netSellCostBuyPrice = netSellCostBuyPrice+220
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063009543725eb and sellbillId = 7798 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:34:48";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:04:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:04:48', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:34:55";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:04:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 10:04:55', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:35:00";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:05:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:05:00', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:35:06";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:05:06", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:05:06', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:07:41', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630095b27fdfb
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:05:06', '0630095b27fdfb', '1', '0.00', '0', '0', '1', '540', '540', '540', '0', '7', '2022-08-20 10:07:41', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','540','0','','0','0','540','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','اضافة فاتورة مبيعات','7799', '0', '2022-08-20 10:07:41', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '540', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 9050;
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 ('220','01074', '7799', '1', '1074', '2', '270', '540', '0', '', '1', '2022-08-20 10:07:41', '1074', '0.00', '0', '7','0','','','0','0','0','0','0','0','1','0','','9050-2,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23407;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 540, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 540, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '62', userid = '4', storedetaildate = '2022-08-20 10:07:41' WHERE storedetailid = '3806';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '7', '2', '1', '7799', 'اضافة فاتورة مبيعات', 'sellbillController.php', '64.00', '62', '4', '2022-08-20 10:07:41','0','0');
UPDATE save SET  savecurrentvalue = '1080',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('540.00','540', '0', '7', 'اضافة فاتورة مبيعات', '7799', '1080', '2022-08-20 10:07:41', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 540, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 540, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 540, 440, 440
                    , 440, 440, 440, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+540, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630095b27fdfb and sellbillId = 7799 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:07:42', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:07:44', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:53";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:07:53', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630096509bc39
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:07:44', '0630096509bc39', '1', '0.00', '0', '0', '1', '210', '210', '-210', '0', '7', '2022-08-20 10:07:53', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-210','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','اضافة فاتورة مردوات مبيعات','2789', '0', '2022-08-20 10:07:53', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '210', '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 ('210.00', '01114', '2789', '1', '1114', '1', '210', '210', '0', '', '0', '0', '1114', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where returnsellbilldetailid = 6072;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1114, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 210, 210, 210
                    , 210, 210, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 210, 210, 210
                    , 210, 210, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '59', userid = '4', storedetaildate = '2022-08-20 10:07:53' WHERE storedetailid = '4049';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1114', '7', '1', '0', '2789', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '58.00', '59', '4', '2022-08-20 10:07:53','0','0');
UPDATE save SET  savecurrentvalue = '870',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1080.00','210', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2789', '870', '2022-08-20 10:07:53', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 210, 210, 210
                    , 210, 210, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 210, 210, 210
                    , 210, 210, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -210, -210, -210
                    , -210, -210, -210, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-210, netSellCostBuyPrice = netSellCostBuyPrice+-210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630096509bc39 and sellbillId = 2789 and returnsellbillId = 2789
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:53";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:07:53', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:55";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 10:07:55', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:37:57";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:07:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 10:07:57', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:01";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:01', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:09";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:09', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:11";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:11', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:26";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:26', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300966b79a85
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:08:11', '06300966b79a85', '1', '0.00', '0', '0', '1', '540', '540', '-540', '0', '7', '2022-08-20 10:08:26', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-540','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','اضافة فاتورة مردوات مبيعات','2790', '0', '2022-08-20 10:08:26', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '540', '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 ('220.00', '01074', '2790', '1', '1074', '2', '270', '540', '0', '', '1', '0', '1074', '0.00', '0','7','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where returnsellbilldetailid = 6073;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 540, 440, 440, 440
                    , 440, 440, 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+540, returnSellCostBuyPrice = returnSellCostBuyPrice+440, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+440
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+440, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+440
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+440
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 540, 440, 440, 440
                    , 440, 440, 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+540, returnSellCostBuyPrice = returnSellCostBuyPrice+440, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+440
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+440, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+440
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+440
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '64', userid = '4', storedetaildate = '2022-08-20 10:08:26' WHERE storedetailid = '3806';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '7', '2', '0', '2790', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '62.00', '64', '4', '2022-08-20 10:08:26','0','0');
UPDATE save SET  savecurrentvalue = '330',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('870.00','540', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2790', '330', '2022-08-20 10:08:26', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 540, 440, 440, 440
                    , 440, 440, 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+540, returnSellCostBuyPrice = returnSellCostBuyPrice+440, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+440
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+440, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+440
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+440
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 540, 440, 440, 440
                    , 440, 440, 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+540, returnSellCostBuyPrice = returnSellCostBuyPrice+440, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+440
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+440, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+440
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+440
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -540, -440, -440
                    , -440, -440, -440, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-540, netSellCostBuyPrice = netSellCostBuyPrice+-440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300966b79a85 and sellbillId = 2790 and returnsellbillId = 2790
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:27";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:27', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:29";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:29", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:29', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:42";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:42', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300967d497f4
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:08:29', '06300967d497f4', '1', '0.00', '0', '0', '1', '440', '440', '440', '0', '7', '2022-08-20 10:08:42', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','440','0','','0','0','440','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','7800', '0', '2022-08-20 10:08:42', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 9050;
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 ('220','01074', '7800', '1', '1074', '2', '220', '440', '0', '', '0', '2022-08-20 10:08:42', '1074', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9050-2,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23408;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 440, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 440, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '62', userid = '4', storedetaildate = '2022-08-20 10:08:42' WHERE storedetailid = '3806';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '7', '2', '1', '7800', 'اضافة فاتورة مبيعات', 'sellbillController.php', '64.00', '62', '4', '2022-08-20 10:08:42','0','0');
UPDATE save SET  savecurrentvalue = '770',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('330.00','440', '0', '7', 'اضافة فاتورة مبيعات', '7800', '770', '2022-08-20 10:08:42', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 440, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 440, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 440, 440, 440
                    , 440, 440, 440, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+440, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300967d497f4 and sellbillId = 7800 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:42";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:43', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 10:08:44', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:38:48";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:08:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:08:48', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:39:00";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:09:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 10:09:00', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:39:06";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:09:06", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-08-20 10:09:06', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 06:39:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 10:09:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 10:09:10', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:33:52";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:03:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:03:52', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:40";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:05:41', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630096a6b01ba
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 10:09:10', '0630096a6b01ba', '1', '0.00', '0', '0', '1', '985', '985', '985', '0', '7', '2022-08-20 11:05:41', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','985','0','','0','0','985','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','اضافة فاتورة مبيعات','7801', '0', '2022-08-20 11:05:41', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '985', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 5904;
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 ('140','00417', '7801', '1', '417', '1', '155', '155', '0', '', '0', '2022-08-20 11:05:41', '417', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','5904-1,');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
                where sellbilldetailid = 23409;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (417, '2022-08-20', 155, 140, 140
                    , 140, 140, 140, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , 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, '2022-08-20', 155, 140, 140
                    , 140, 140, 140, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , 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 = '4', storedetaildate = '2022-08-20 11:05:41' WHERE storedetailid = '3277';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('417', '7', '1', '1', '7801', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '4', '2022-08-20 11:05:41','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('180','00669', '7801', '1', '669', '1', '180', '180', '0', '', '0', '2022-08-20 11:05:41', '669', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
                where sellbilldetailid = 23410;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (669, '2022-08-20', 180, 180, 180
                    , 180, 180, 180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , 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, '2022-08-20', 180, 180, 180
                    , 180, 180, 180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , 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 = '40', userid = '4', storedetaildate = '2022-08-20 11:05:41' WHERE storedetailid = '2062';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('669', '7', '1', '1', '7801', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41.00', '40', '4', '2022-08-20 11:05:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9098;
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 ('210','01122', '7801', '1', '1122', '1', '220', '220', '0', '', '0', '2022-08-20 11:05:41', '1122', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9098-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23411;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1122, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '43', userid = '4', storedetaildate = '2022-08-20 11:05:41' WHERE storedetailid = '4101';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '7', '1', '1', '7801', 'اضافة فاتورة مبيعات', 'sellbillController.php', '44.00', '43', '4', '2022-08-20 11:05:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9100;
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 ('210','01125', '7801', '1', '1125', '1', '220', '220', '0', '', '0', '2022-08-20 11:05:41', '1125', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9100-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23412;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1125, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 = '2022-08-20 11:05:41' WHERE storedetailid = '4102';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '7', '1', '1', '7801', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32.00', '31', '4', '2022-08-20 11:05:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9094;
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 ('200','01123', '7801', '1', '1123', '1', '210', '210', '0', '', '0', '2022-08-20 11:05:41', '1123', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9094-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23413;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1123, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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 = '42', userid = '4', storedetaildate = '2022-08-20 11:05:41' WHERE storedetailid = '4099';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '7', '1', '1', '7801', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43.00', '42', '4', '2022-08-20 11:05:41','0','0');
UPDATE save SET  savecurrentvalue = '1755',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('770.00','985', '0', '7', 'اضافة فاتورة مبيعات', '7801', '1755', '2022-08-20 11:05:41', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 985, 940, 940
                    , 940, 940, 940, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+985, sellCostBuyPrice =sellCostBuyPrice+940
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+940, sellCostMeanBuyPrice = sellCostMeanBuyPrice+940
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+940, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+940
                            , 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, '2022-08-20', 985, 940, 940
                    , 940, 940, 940, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+985, sellCostBuyPrice =sellCostBuyPrice+940
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+940, sellCostMeanBuyPrice = sellCostMeanBuyPrice+940
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+940, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+940
                            , 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, 985, 940, 940
                    , 940, 940, 940, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+985, netSellCostBuyPrice = netSellCostBuyPrice+940
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+940
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+940
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+940
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+940
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630096a6b01ba and sellbillId = 7801 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:05:41', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:05:44', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300a37870281
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 11:03:52', '06300a37870281', '1', '0.00', '0', '0', '1', '535', '535', '-535', '0', '7', '2022-08-20 11:05:44', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '3', '0', '', '','','','-1','0','0','0','','0','-535','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','اضافة فاتورة مردوات مبيعات','2791', '0', '2022-08-20 11:05:44', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '535', '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 ('200.00', '00945', '2791', '1', '945', '1', '200', '200', '0', '', '0', '0', '945', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where returnsellbilldetailid = 6074;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (945, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 200, 200, 200
                    , 200, 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 200, 200, 200
                    , 200, 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '32', userid = '4', storedetaildate = '2022-08-20 11:05:44' WHERE storedetailid = '3345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('945', '7', '1', '0', '2791', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '31.00', '32', '4', '2022-08-20 11:05:44','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 ('165.00', '00706', '2791', '1', '706', '1', '165', '165', '0', '', '0', '0', '706', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 157.50, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 157.50
                where returnsellbilldetailid = 6075;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (706, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 165, 165, 150, 157.5
                    , 150, 157.5, 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+165, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+150
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+157.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+150
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+157.5
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 165, 165, 150, 157.5
                    , 150, 157.5, 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+165, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+150
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+157.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+150
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+157.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '5', userid = '4', storedetaildate = '2022-08-20 11:05:44' WHERE storedetailid = '2103';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('706', '7', '1', '0', '2791', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4.00', '5', '4', '2022-08-20 11:05:44','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 ('170.00', '01073', '2791', '1', '1073', '1', '170', '170', '0', '', '0', '0', '1073', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where returnsellbilldetailid = 6076;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1073, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 170, 170, 170, 170
                    , 170, 170, 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+170, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 170, 170, 170, 170
                    , 170, 170, 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+170, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '4', storedetaildate = '2022-08-20 11:05:44' WHERE storedetailid = '3802';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1073', '7', '1', '0', '2791', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3.00', '4', '4', '2022-08-20 11:05:44','0','0');
UPDATE save SET  savecurrentvalue = '1220',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1755.00','535', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2791', '1220', '2022-08-20 11:05:44', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 535, 535, 520, 527.5
                    , 520, 527.5, 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+535, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+527.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+527.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 535, 535, 520, 527.5
                    , 520, 527.5, 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+535, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+520
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+527.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+520
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+527.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -535, -535, -520
                    , -527.5, -520, -527.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-535, netSellCostBuyPrice = netSellCostBuyPrice+-535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-520
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-527.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-520
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-527.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300a37870281 and sellbillId = 2791 and returnsellbillId = 2791
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:05:45', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:48";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:05:49', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:53";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-08-20 11:05:53', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:35:54";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:05:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:05:54', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:36:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:06:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:06:03', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:36:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:06:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:06:03', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:54:06";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:24:06", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:24:06', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300a3fc02eae
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 11:06:04', '06300a3fc02eae', '1', '0.00', '0', '0', '1', '250', '250', '250', '0', '7', '2022-08-20 11:24:06', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','250','0','','0','0','250','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','اضافة فاتورة مبيعات','7802', '0', '2022-08-20 11:24:06', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8836;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01071', '7802', '1', '1071', '1', '250', '250', '0', '', '0', '2022-08-20 11:24:06', '1071', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','8836-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 23414;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1071, '2022-08-20', 250, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 250, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '4', storedetaildate = '2022-08-20 11:24:06' WHERE storedetailid = '3792';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1071', '7', '1', '1', '7802', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '4', '2022-08-20 11:24:06','0','0');
UPDATE save SET  savecurrentvalue = '1470',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1220.00','250', '0', '7', 'اضافة فاتورة مبيعات', '7802', '1470', '2022-08-20 11:24:06', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 250, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 250, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 250, 250, 250
                    , 250, 250, 250, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+250, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300a3fc02eae and sellbillId = 7802 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:54:07";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:24:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:24:07', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:54:09";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:24:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:24:09', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 07:54:11";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 11:24:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:24:11', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:09:33";

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 062ff8dc3ce2cd
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-19 15:18:59', '062ff8dc3ce2cd', '1', '0.00', '0', '0', '1', '320', '320', '320', '0', '4', '2022-08-20 11:39:33', '', null, '0', 'نقدي', '4', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','320','0','','0','0','320','0','0','0','0','0','0','0','0','');
ROLLBACK;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 062ff8dc3ce2cd and sellbillId = 0 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:09:34";
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:09: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 < "2022-08-20 08:09:38";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:39:38", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 11:39:38', '6', '', '156.217.194.191', '', '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 < "2022-08-20 08:09:39";
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 < "2022-08-20 08:09:50";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:39:50", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:39:50', '6', '', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:09:52";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:39:52", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:39:52', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:05";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:05", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:40:05', '6', 'addAndRetuen', '156.217.194.191', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300abe880963
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 11:39:52', '06300abe880963', '1', '0.00', '0', '0', '1', '180', '180', '-180', '0', '4', '2022-08-20 11:40:05', '', '6', '0', 'نقدي','4', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-180','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '6' 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','اضافة فاتورة مردوات مبيعات','2792', '0', '2022-08-20 11:40:05', '6', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '180', '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 ('165.00', '00467', '2792', '1', '467', '1', '180.00', '180', '0', '', '0', '0', '467', '0.00', '0','4','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
                where returnsellbilldetailid = 6077;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (467, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 165, 165, 165
                    , 165, 165, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                            , 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 (4, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 165, 165, 165
                    , 165, 165, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '6', storedetaildate = '2022-08-20 11:40:05' WHERE storedetailid = '3466';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('467', '4', '1', '0', '2792', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '18.00', '19', '6', '2022-08-20 11:40:05','0','0');
UPDATE save SET  savecurrentvalue = '875',  userid = '6' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1055.00','180', '1', '4', 'اضافة فاتورة مردوات مبيعات', '2792', '875', '2022-08-20 11:40:05', '6',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 165, 165, 165
                    , 165, 165, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 165, 165, 165
                    , 165, 165, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -180, -165, -165
                    , -165, -165, -165, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-180, netSellCostBuyPrice = netSellCostBuyPrice+-165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300abe880963 and sellbillId = 2792 and returnsellbillId = 2792
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:05";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:05", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:40:05', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:06";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:06", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:40:06', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:25";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:25", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:40:25', '6', 'addAndRetuen', '156.217.194.191', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300abf67a3bd
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 11:40:06', '06300abf67a3bd', '1', '0.00', '0', '0', '1', '330', '330', '330', '0', '4', '2022-08-20 11:40:25', '', '6', '0', 'نقدي', '4', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','330','0','','0','0','330','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '6' 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','اضافة فاتورة مبيعات','7803', '0', '2022-08-20 11:40:25', '6', 'sellbillController.php', 'اضافة فاتورة مبيعات', '330', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8460;
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 ('280','00647', '7803', '1', '647', '1', '330.00', '330', '0', '', '2', '2022-08-20 11:40:25', '647', '0.00', '0', '4','0','','','0','0','0','0','0','0','2','0','','8460-1,');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 304.38, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 304.38
                where sellbilldetailid = 23415;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (647, '2022-08-20', 330, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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 (4, '2022-08-20', 330, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '34', userid = '6', storedetaildate = '2022-08-20 11:40:25' WHERE storedetailid = '2890';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '4', '1', '1', '7803', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35.00', '34', '6', '2022-08-20 11:40:25','0','0');
UPDATE save SET  savecurrentvalue = '1205',  userid = '6' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('875.00','330', '0', '4', 'اضافة فاتورة مبيعات', '7803', '1205', '2022-08-20 11:40:25', '6',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 330, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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, '2022-08-20', 330, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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, 330, 320, 280
                    , 304.38, 280, 304.38, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+330, netSellCostBuyPrice = netSellCostBuyPrice+320
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+304.38
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+304.38
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300abf67a3bd and sellbillId = 7803 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:26";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:26", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:40:26', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:10:27";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:40:27", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:40:27', '6', '', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:12:33";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 11:42:33", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:42:34', '6', '', '156.217.194.191', '', '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 < "2022-08-20 08:17:08";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:47:08", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 11:47:08', '3', '', '197.41.155.29', '', '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 < "2022-08-20 08:17:09";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:17:19";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:47:20", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:47:20', '3', 'addsellBill', '197.41.155.29', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:26:18";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:56:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 11:56:18', '3', '', '197.41.155.29', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:26:23";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:56:23", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 11:56:23', '3', '', '197.41.155.29', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:26:29";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:56:29", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 11:56:29', '3', 'add', '197.41.155.29', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'تاكسي', '', '80', '2022-08-20', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '-80',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('0.00','80', '1', '8', 'إضافة مصروف', '1660', '-80', '2022-08-20 11:56:29', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '80', '80', '2022-08-20', '3', '0', '0', '2022-08-20 11:56:29','اضافة اسم مصروف( تاكسي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4451', '160', '80', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-671080', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4451', '142', '80', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-747748', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'تاكسي', expensesdetails = '', expensesValue = '80.00', expensesdate = '2022-08-20', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '4451', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1660';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:26:37";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:56:37", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 11:56:37', '3', 'show', '197.41.155.29', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:28:53";
UPDATE user SET loginip = "197.41.155.29", lastactivetime = "2022-08-20 11:58:54", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 11:58:54', '3', 'addsellBill', '197.41.155.29', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:32:27";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:02:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:02:27', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:32:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:02:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:02:41', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300b133e46af
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 12:02:27', '06300b133e46af', '1', '0.00', '0', '0', '1', '265', '265', '-265', '0', '7', '2022-08-20 12:02:41', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-265','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','اضافة فاتورة مردوات مبيعات','2793', '0', '2022-08-20 12:02:41', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '265', '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 ('265.00', '01062', '2793', '1', '1062', '1', '265', '265', '0', '', '0', '0', '1062', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
                where returnsellbilldetailid = 6078;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1062, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 265, 265, 265, 265
                    , 265, 265, 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+265, returnSellCostBuyPrice = returnSellCostBuyPrice+265, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+265
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+265, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+265
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+265
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 265, 265, 265, 265
                    , 265, 265, 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+265, returnSellCostBuyPrice = returnSellCostBuyPrice+265, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+265
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+265, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+265
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+265
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '42', userid = '4', storedetaildate = '2022-08-20 12:02:41' WHERE storedetailid = '3726';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '7', '1', '0', '2793', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '41.00', '42', '4', '2022-08-20 12:02:41','0','0');
UPDATE save SET  savecurrentvalue = '1205',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1470.00','265', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2793', '1205', '2022-08-20 12:02:41', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 265, 265, 265, 265
                    , 265, 265, 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+265, returnSellCostBuyPrice = returnSellCostBuyPrice+265, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+265
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+265, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+265
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+265
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 265, 265, 265, 265
                    , 265, 265, 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+265, returnSellCostBuyPrice = returnSellCostBuyPrice+265, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+265
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+265, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+265
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+265
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -265, -265, -265
                    , -265, -265, -265, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-265, netSellCostBuyPrice = netSellCostBuyPrice+-265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-265
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-265
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300b133e46af and sellbillId = 2793 and returnsellbillId = 2793
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:32:42";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:02:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:02:42', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:32:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:02:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:02:44', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:33:02";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:03:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:03:03', '4', 'addAndRetuen', '41.233.78.177', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300a83b89439
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 11:24:11', '06300a83b89439', '1', '0.00', '0', '0', '1', '660', '660', '660', '0', '7', '2022-08-20 12:03:03', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','660','0','','0','0','660','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','اضافة فاتورة مبيعات','7804', '0', '2022-08-20 12:03:03', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '660', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9100;
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 ('210','01125', '7804', '1', '1125', '1', '220', '220', '0', '', '0', '2022-08-20 12:03:03', '1125', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9100-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23416;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1125, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '4', storedetaildate = '2022-08-20 12:03:03' WHERE storedetailid = '4102';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '7', '1', '1', '7804', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31.00', '30', '4', '2022-08-20 12:03:03','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9098;
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 ('210','01122', '7804', '1', '1122', '1', '220', '220', '0', '', '0', '2022-08-20 12:03:03', '1122', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9098-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23417;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1122, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 = '42', userid = '4', storedetaildate = '2022-08-20 12:03:03' WHERE storedetailid = '4101';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '7', '1', '1', '7804', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43.00', '42', '4', '2022-08-20 12:03:03','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9050;
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 ('220','01074', '7804', '1', '1074', '1', '220', '220', '0', '', '0', '2022-08-20 12:03:03', '1074', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9050-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23418;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 220, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 220, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 = '61', userid = '4', storedetaildate = '2022-08-20 12:03:03' WHERE storedetailid = '3806';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '7', '1', '1', '7804', 'اضافة فاتورة مبيعات', 'sellbillController.php', '62.00', '61', '4', '2022-08-20 12:03:03','0','0');
UPDATE save SET  savecurrentvalue = '1865',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1205.00','660', '0', '7', 'اضافة فاتورة مبيعات', '7804', '1865', '2022-08-20 12:03:03', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 660, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 660, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 660, 640, 640
                    , 640, 640, 640, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+660, netSellCostBuyPrice = netSellCostBuyPrice+640
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+640
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+640
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+640
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+640
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300a83b89439 and sellbillId = 7804 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:33:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:03:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:03:03', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:33:06";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:03:06", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 12:03:06', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:33:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:03:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:03:10', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:33:12";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:03:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-08-20 12:03:12', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 08:40:35";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 12:10:35", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:10:35', '4', 'addsellBill', '41.233.78.177', '', '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 < "2022-08-20 09:18:09";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 12:48:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 12:48:09', '7', '', '197.192.206.104', '', '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 < "2022-08-20 09:18:09";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
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 < "2022-08-20 09:24:14";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:54:14", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 12:54:14', '5', '', '197.55.121.223', '', '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 < "2022-08-20 09:24:14";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:24:17";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:54:17", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:54:17', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:27:56";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:57:56", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:57:56', '5', 'addAndRetuen', '197.55.121.223', '', '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 06300bd59d776a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(39,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2022-08-20 12:54:17', '06300bd59d776a', '39', '-35.00', '335', '0', '1', '370', '370', '0', '370', '3', '2022-08-20 12:57:56', '', '5', '0', 'ام محمود الحضره', '3', '1', '3', '0', 'ام محمود الحضره', '2' ,'0','','','','','-1','0','0','0','0','0','370','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '335', userid = '5' WHERE clientid = '39';
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 ('39','-35.00','370','0','اضافة فاتورة مبيعات','7805', '335', '2022-08-20 12:57:56', '5', 'sellbillController.php', 'اضافة فاتورة مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','370','1');
UPDATE client SET  inUse = 0 where clientid = 39;
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 ('175','00299', '7805', '1', '299', '2', '184.99', '370', '0', '', '2', '2022-08-20 12:57:56', '299', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 165.00
                where sellbilldetailid = 23419;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (299, '2022-08-20', 370, 350, 310
                    , 330, 310, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, 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+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (3, '2022-08-20', 370, 350, 310
                    , 330, 310, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, 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 = '5', userid = '5', storedetaildate = '2022-08-20 12:57:56' WHERE storedetailid = '2019';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('299', '3', '2', '1', '7805', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '5', '5', '2022-08-20 12:57:56','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 370, 350, 310
                    , 330, 310, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, 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 (39, '2022-08-20', 370, 350, 310
                    , 330, 310, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, 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, 350, 310
                    , 330, 310, 330, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+370, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300bd59d776a and sellbillId = 7805 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:27:56";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:57:56", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:57:56', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:27:59";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:57:59", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:57:59', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:06";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 12:58:06', '5', '', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:06";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 12:58:06', '5', '', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:10";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:10", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:58:10', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:50";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:50", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:58:50', '5', 'addAndRetuen', '197.55.121.223', '', '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 06300be4285f72
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(39,@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 ('2022-08-20 12:58:10', '06300be4285f72', '39', '335.00', '-35', '0', '1', '370', '370', '0', '-370', '3', '2022-08-20 12:58:50', '', '5', '0', 'ام محمود الحضره','3', '1', '5', '0', 'ام محمود الحضره', '2', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-35', userid = '5' WHERE clientid = '39';
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 ('39','335.00','370','1','اضافة فاتورة مردوات مبيعات','2794', '-35', '2022-08-20 12:58:50', '5', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','370','1');
UPDATE client SET  inUse = 0 where clientid = 39;
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 ('185.00', '00762', '2794', '1', '762', '1', '195.00', '195', '0', '', '2', '0', '762', '0.00', '0','3','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 177.50, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 177.50
                where returnsellbilldetailid = 6079;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (762, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 195, 185, 170, 177.5
                    , 170, 177.5, 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+195, returnSellCostBuyPrice = returnSellCostBuyPrice+185, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+177.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+177.5
                            , 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 (3, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 195, 185, 170, 177.5
                    , 170, 177.5, 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+195, returnSellCostBuyPrice = returnSellCostBuyPrice+185, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+177.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+177.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '5', storedetaildate = '2022-08-20 12:58:50' WHERE storedetailid = '2196';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('762', '3', '1', '0', '2794', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1.00', '2', '5', '2022-08-20 12:58:50','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 ('160.00', '00193', '2794', '1', '193', '1', '175.00', '175', '0', '', '2', '0', '193', '0.00', '0','3','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where returnsellbilldetailid = 6080;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (193, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 175, 160, 160, 160
                    , 160, 160, 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+175, returnSellCostBuyPrice = returnSellCostBuyPrice+160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+160
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+160, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+160
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+160
                            , 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 (3, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 175, 160, 160, 160
                    , 160, 160, 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+175, returnSellCostBuyPrice = returnSellCostBuyPrice+160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+160
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+160, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+160
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+160
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '5', storedetaildate = '2022-08-20 12:58:50' WHERE storedetailid = '1426';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('193', '3', '1', '0', '2794', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '5.00', '6', '5', '2022-08-20 12:58:50','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 345, 330, 337.5
                    , 330, 337.5, 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+345, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+337.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+337.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (39, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 345, 330, 337.5
                    , 330, 337.5, 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+345, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+337.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+337.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -370, -345, -330
                    , -337.5, -330, -337.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-370, netSellCostBuyPrice = netSellCostBuyPrice+-345
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-337.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-337.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300be4285f72 and sellbillId = 2794 and returnsellbillId = 2794
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:51";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:58:51', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:54";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:54", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:58:55', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:28:57";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:58:57", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 12:58:57', '5', '', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:29:01";
UPDATE user SET loginip = "197.55.121.223", lastactivetime = "2022-08-20 12:59:01", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 12:59:01', '5', 'addsellBill', '197.55.121.223', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:31:19";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 13:01:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:01:19', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:47:50";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:17:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 13:17:50', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:51:18";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:21:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:21:18', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:16";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:22:17', '4', 'addAndRetuen', '41.233.78.177', '', '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 06300c3ae6a2e4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(127,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2022-08-20 13:21:18', '06300c3ae6a2e4', '127', '3490.00', '6070', '0', '1', '2580', '2580', '0', '2580', '7', '2022-08-20 13:22:17', '', '4', '0', 'عدلي عدلي', '7', '1', '3', '0', 'عدلي عدلي', '12' ,'0','','','','','-1','0','0','0','0','0','2580','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '6070', userid = '4' WHERE clientid = '127';
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 ('127','3490.00','2580','0','اضافة فاتورة مبيعات','7806', '6070', '2022-08-20 13:22:17', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2580', '0', null, '0', null, null,'', '0','1','1','2580','1');
UPDATE client SET  inUse = 0 where clientid = 127;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+6 where id = 9094;
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 ('200','01123', '7806', '1', '1123', '6', '210', '1260', '0', '', '0', '2022-08-20 13:22:17', '1123', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9094-6,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23420;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1123, '2022-08-20', 1260, 1200, 1200
                    , 1200, 1200, 1200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+6
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 1260, 1200, 1200
                    , 1200, 1200, 1200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '4', storedetaildate = '2022-08-20 13:22:17' WHERE storedetailid = '4099';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '7', '6', '1', '7806', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42.00', '36', '4', '2022-08-20 13:22:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+6 where id = 9098;
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 ('210','01122', '7806', '1', '1122', '6', '220', '1320', '0', '', '0', '2022-08-20 13:22:17', '1122', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9098-6,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23421;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1122, '2022-08-20', 1320, 1260, 1260
                    , 1260, 1260, 1260, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1320, sellCostBuyPrice =sellCostBuyPrice+1260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+6
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 1320, 1260, 1260
                    , 1260, 1260, 1260, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1320, sellCostBuyPrice =sellCostBuyPrice+1260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '4', storedetaildate = '2022-08-20 13:22:17' WHERE storedetailid = '4101';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '7', '6', '1', '7806', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42.00', '36', '4', '2022-08-20 13:22:17','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 2580, 2460, 2460
                    , 2460, 2460, 2460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2460
                            , 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 (127, '2022-08-20', 2580, 2460, 2460
                    , 2460, 2460, 2460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2460
                            , 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, 2580, 2460, 2460
                    , 2460, 2460, 2460, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2580, netSellCostBuyPrice = netSellCostBuyPrice+2460
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2460
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2460
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2460
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2460
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300c3ae6a2e4 and sellbillId = 7806 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:17";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:17", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:22:17', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:21";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:22:21', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:23";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 13:22:23', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:28";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 13:22:28', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:35";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 13:22:36', '4', 'show', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:40";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:22:40', '4', 'showDetail', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 09:52:49";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:22:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:22:49', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:02:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:32:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 13:32:41', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:02:50";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 13:32:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 13:32:50', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:34:39";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:04:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:04:39', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:34:57";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:04:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:04:57', '4', 'add', '41.233.78.177', '', '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 =11790
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(108,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '42380' , clientdate = '2022-08-20 14:04:58', userid = '4' WHERE clientid = '108';
UPDATE client SET  inUse = 0 where clientid = 108;
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 ('108','43880.00','1500','1','ايصال تحصيل (( قبض من عميل ))','11790', '42380', '2022-08-20 14:04:39', '4', 'clientPayedDeptController.php', '   ', '1500', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '3365',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1865.00','1500', '0', '7', 'ايصال تحصيل (( قبض من عميل ))', '11790', '3365', '2022-08-20 14:04:58', '4',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1500', '1500', '2022-08-20', '4', '0', '0', '2022-08-20 14:04:58','اضافة ايصال سداد للعميل عزت ورده','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4452', '141', '1500', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-888070', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4452', '184', '1500', '','0');
UPDATE accountstree SET name = 'عزت ورده', customName = 'عزت ورده', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '4', mydate = '2022-02-26', itemtype2 = '1', theValue = '-127500', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '184';
UPDATE clientdebtchange SET clientid = '108', clientdebtchangebefore = '43880.00', clientdebtchangeamount = '1500.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '11790', clientdebtchangeafter = '42380.00', clientdebtchangedate = '2022-08-20 14:04:39', userid = '4', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1500.00',discount='', reciptid=null, dailyentryid = '4452',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '11790';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:34:58";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:04:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:04:58', '4', 'editprint2', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:35:05";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:05:05", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:05:05', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:35:08";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:05:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:05:08', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:35:38";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:05:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:05:38', '4', 'addAndRetuen', '41.233.78.177', '', '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 06300cdf45c009
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(203,@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 ('2022-08-20 14:05:08', '06300cdf45c009', '203', '15840.00', '12840', '0', '1', '3000', '3000', '0', '-3000', '7', '2022-08-20 14:05:38', '', '4', '0', 'محمد حسين ابو ادم','7', '1', '5', '0', 'محمد حسين ابو ادم', '15', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '12840', userid = '4' WHERE clientid = '203';
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 ('203','15840.00','3000','1','اضافة فاتورة مردوات مبيعات','2795', '12840', '2022-08-20 14:05:38', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '3000', '0', null, '0', null, null,'', '0','1','1','3000','1');
UPDATE client SET  inUse = 0 where clientid = 203;
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 ('200.00', '00799', '2795', '1', '799', '15', '200', '3000', '0', '', '0', '0', '799', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where returnsellbilldetailid = 6081;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (799, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3000, 3000, 3000, 3000
                    , 3000, 3000, 0, 0, 15)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+3000, returnSellCostBuyPrice = returnSellCostBuyPrice+3000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3000
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+15;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3000, 3000, 3000, 3000
                    , 3000, 3000, 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+3000, returnSellCostBuyPrice = returnSellCostBuyPrice+3000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '132', userid = '4', storedetaildate = '2022-08-20 14:05:38' WHERE storedetailid = '3279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('799', '7', '15', '0', '2795', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '117.00', '132', '4', '2022-08-20 14:05:38','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3000, 3000, 3000, 3000
                    , 3000, 3000, 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+3000, returnSellCostBuyPrice = returnSellCostBuyPrice+3000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (203, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 3000, 3000, 3000, 3000
                    , 3000, 3000, 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+3000, returnSellCostBuyPrice = returnSellCostBuyPrice+3000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -3000, -3000, -3000
                    , -3000, -3000, -3000, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-3000, netSellCostBuyPrice = netSellCostBuyPrice+-3000
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-3000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-3000
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-3000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-3000
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300cdf45c009 and sellbillId = 2795 and returnsellbillId = 2795
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:35:38";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:05:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:05:39', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:35:44";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:05:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:05:44', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:36:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:06:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:06:10', '4', 'addAndRetuen', '41.233.78.177', '', '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 06300ce1864841
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(127,@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 ('2022-08-20 14:05:44', '06300ce1864841', '127', '6070.00', '4070', '0', '1', '2000', '2000', '0', '-2000', '7', '2022-08-20 14:06:10', '', '4', '0', 'عدلي عدلي','7', '1', '5', '0', 'عدلي عدلي', '10', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '4070', userid = '4' WHERE clientid = '127';
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 ('127','6070.00','2000','1','اضافة فاتورة مردوات مبيعات','2796', '4070', '2022-08-20 14:06:10', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '2000', '0', null, '0', null, null,'', '0','1','1','2000','1');
UPDATE client SET  inUse = 0 where clientid = 127;
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 ('200.00', '00799', '2796', '1', '799', '10', '200.00', '2000', '0', '', '0', '0', '799', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where returnsellbilldetailid = 6082;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (799, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2000, 2000, 2000, 2000
                    , 2000, 2000, 0, 0, 10)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+2000, returnSellCostBuyPrice = returnSellCostBuyPrice+2000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2000
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+10;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2000, 2000, 2000, 2000
                    , 2000, 2000, 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+2000, returnSellCostBuyPrice = returnSellCostBuyPrice+2000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '142', userid = '4', storedetaildate = '2022-08-20 14:06:10' WHERE storedetailid = '3279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('799', '7', '10', '0', '2796', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '132.00', '142', '4', '2022-08-20 14:06:10','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2000, 2000, 2000, 2000
                    , 2000, 2000, 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+2000, returnSellCostBuyPrice = returnSellCostBuyPrice+2000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (127, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2000, 2000, 2000, 2000
                    , 2000, 2000, 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+2000, returnSellCostBuyPrice = returnSellCostBuyPrice+2000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -2000, -2000, -2000
                    , -2000, -2000, -2000, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-2000, netSellCostBuyPrice = netSellCostBuyPrice+-2000
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-2000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-2000
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-2000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-2000
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300ce1864841 and sellbillId = 2796 and returnsellbillId = 2796
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:36:11";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:06:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:06:11', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:36:31";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:06:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:06:31', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:36:36";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:06:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:06:36', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:36:38";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:06:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:06:38', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:01";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:01', '4', 'add', '41.233.78.177', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'مصرةف تروسيكل', '', '30', '2022-08-20', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3335',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3365.00','30', '1', '7', 'إضافة مصروف', '1661', '3335', '2022-08-20 14:07:01', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '30', '30', '2022-08-20', '4', '0', '0', '2022-08-20 14:07:01','اضافة اسم مصروف( مصرةف تروسيكل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4453', '160', '30', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-671110', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4453', '141', '30', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-888100', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'مصرةف تروسيكل', expensesdetails = '', expensesValue = '30.00', expensesdate = '2022-08-20', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4453', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1661';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:02";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:02", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:02', '4', 'sucess', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:03', '4', 'show', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:05";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:05", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:05', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:20";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:20", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:20', '4', 'add', '41.233.78.177', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'قبض العميد', '', '900', '2022-08-20', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2435',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3335.00','900', '1', '7', 'إضافة مصروف', '1662', '2435', '2022-08-20 14:07:20', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '900', '900', '2022-08-20', '4', '0', '0', '2022-08-20 14:07:20','اضافة اسم مصروف( قبض العميد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4454', '160', '900', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-672010', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4454', '141', '900', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-889000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'قبض العميد', expensesdetails = '', expensesValue = '900.00', expensesdate = '2022-08-20', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4454', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1662';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:21";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:07:21', '4', 'sucess', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:22";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:07:22', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:25";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:07:25', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:52";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:07:52', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:37:55";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:07:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:07:55', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:38:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:08:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:08:03', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:38:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:08:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:08:10', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:38:54";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:08:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:08:54', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:39:01";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:09:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:09:01', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:41:37";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:11:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:11:37', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:41:57";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:11:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:11:57', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:42:29";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:12:29", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:12:29', '4', 'addAndRetuen', '41.233.78.177', '', '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 06300cf8d4b8dd
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(129,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2022-08-20 14:11:57', '06300cf8d4b8dd', '129', '30900.00', '31110', '0', '1', '210', '210', '0', '210', '7', '2022-08-20 14:12:29', '', '4', '0', 'احمد غنيم', '7', '1', '3', '0', 'احمد غنيم', '1' ,'0','','','','','-1','0','0','0','0','0','210','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '31110', userid = '4' WHERE clientid = '129';
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 ('129','30900.00','210','0','اضافة فاتورة مبيعات','7807', '31110', '2022-08-20 14:12:29', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','210','1');
UPDATE client SET  inUse = 0 where clientid = 129;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8818;
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 ('210','01114', '7807', '1', '1114', '1', '210', '210', '0', '', '0', '2022-08-20 14:12:29', '1114', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','8818-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23422;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1114, '2022-08-20', 210, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 210, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 = '58', userid = '4', storedetaildate = '2022-08-20 14:12:29' WHERE storedetailid = '4049';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1114', '7', '1', '1', '7807', 'اضافة فاتورة مبيعات', 'sellbillController.php', '59.00', '58', '4', '2022-08-20 14:12:29','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 210, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 (129, '2022-08-20', 210, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, 210, 210, 210
                    , 210, 210, 210, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, netSellCostBuyPrice = netSellCostBuyPrice+210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300cf8d4b8dd and sellbillId = 7807 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:42:30";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:12:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:12:30', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:42:33";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:12:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:12:33', '4', '', '41.233.78.177', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:42:54";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 14:12:54", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 14:12:54', '8', '', '154.176.79.137', '', '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 < "2022-08-20 10:42:54";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:42:56";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 14:12:56", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:12:56', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:13:03', '4', 'add', '41.233.78.177', '', '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 =11794
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(129,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '29610' , clientdate = '2022-08-20 14:13:03', userid = '4' WHERE clientid = '129';
UPDATE client SET  inUse = 0 where clientid = 129;
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 ('129','31110.00','1500','1','ايصال تحصيل (( قبض من عميل ))','11794', '29610', '2022-08-20 14:12:33', '4', 'clientPayedDeptController.php', '   ', '1500', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '3935',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2435.00','1500', '0', '7', 'ايصال تحصيل (( قبض من عميل ))', '11794', '3935', '2022-08-20 14:13:03', '4',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1500', '1500', '2022-08-20', '4', '0', '0', '2022-08-20 14:13:03','اضافة ايصال سداد للعميل احمد غنيم','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4455', '141', '1500', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-887500', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4455', '205', '1500', '','0');
UPDATE accountstree SET name = 'احمد غنيم', customName = 'احمد غنيم', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '4', mydate = '2022-03-10', itemtype2 = '1', theValue = '-45500', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '205';
UPDATE clientdebtchange SET clientid = '129', clientdebtchangebefore = '31110.00', clientdebtchangeamount = '1500.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '11794', clientdebtchangeafter = '29610.00', clientdebtchangedate = '2022-08-20 14:12:33', userid = '4', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1500.00',discount='', reciptid=null, dailyentryid = '4455',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '11794';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:03";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:13:03', '4', 'editprint2', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:13:10', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:30";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:13:30', '4', 'add', '41.233.78.177', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'الرواتر والنت', '', '250', '2022-08-20', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3685',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3935.00','250', '1', '7', 'إضافة مصروف', '1663', '3685', '2022-08-20 14:13:30', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '250', '250', '2022-08-20', '4', '0', '0', '2022-08-20 14:13:30','اضافة اسم مصروف( الرواتر والنت )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4456', '160', '250', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-672260', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4456', '141', '250', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-887750', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'الرواتر والنت', expensesdetails = '', expensesValue = '250.00', expensesdate = '2022-08-20', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4456', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1663';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:31";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:13:31', '4', 'sucess', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:33";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:13:33', '4', 'show', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:33";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:13:33', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:41";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 14:13:41', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:45";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:13:45', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:43:47";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:13:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:13:47', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:45:12";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:15:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:15:12', '4', 'addAndRetuen', '41.233.78.177', '', '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 06300cffba7574
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(129,@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 ('2022-08-20 14:13:47', '06300cffba7574', '129', '29610.00', '28090', '0', '1', '1520', '1520', '0', '-1520', '7', '2022-08-20 14:15:12', '', '4', '0', 'احمد غنيم','7', '1', '5', '0', 'احمد غنيم', '8', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '28090', userid = '4' WHERE clientid = '129';
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 ('129','29610.00','1520','1','اضافة فاتورة مردوات مبيعات','2797', '28090', '2022-08-20 14:15:12', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '1520', '0', null, '0', null, null,'', '0','1','1','1520','1');
UPDATE client SET  inUse = 0 where clientid = 129;
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 ('185.00', '00621', '2797', '1', '621', '8', '190', '1520', '0', '', '0', '0', '621', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
                where returnsellbilldetailid = 6083;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (621, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1520, 1480, 1480, 1480
                    , 1480, 1480, 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+1520, returnSellCostBuyPrice = returnSellCostBuyPrice+1480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1480
                            , 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 (7, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1520, 1480, 1480, 1480
                    , 1480, 1480, 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+1520, returnSellCostBuyPrice = returnSellCostBuyPrice+1480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1480
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '32', userid = '4', storedetaildate = '2022-08-20 14:15:12' WHERE storedetailid = '3732';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('621', '7', '8', '0', '2797', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '24.00', '32', '4', '2022-08-20 14:15:12','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1520, 1480, 1480, 1480
                    , 1480, 1480, 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+1520, returnSellCostBuyPrice = returnSellCostBuyPrice+1480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1480
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (129, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1520, 1480, 1480, 1480
                    , 1480, 1480, 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+1520, returnSellCostBuyPrice = returnSellCostBuyPrice+1480, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1480
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1480
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1480
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -1520, -1480, -1480
                    , -1480, -1480, -1480, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-1520, netSellCostBuyPrice = netSellCostBuyPrice+-1480
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1480
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-1480
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1480
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-1480
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300cffba7574 and sellbillId = 2797 and returnsellbillId = 2797
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:45:12";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:15:13", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:15:13', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:45:17";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:15:17", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:15:17', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:45:34";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:15:35", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:15:35', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:47:28";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:17:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 14:17:29', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:47:37";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:17:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 14:17:38', '4', 'show', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:48:09";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:18:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 14:18:09', '4', 'editprint', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:48:26";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:18:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:18:26', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:49:08";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:19:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:19:09', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:49:40";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:19:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:19:41', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:49:48";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:19:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:19:48', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:50:31";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:20:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:20:31', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:50:37";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:20:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:20:37', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:51:10";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:21:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:21:10', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:51:19";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:21:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 14:21:19', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:51:32";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:21:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2022-08-20 14:21:32', '4', 'show', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:51:39";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:21:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:21:39', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:52:38";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:22:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:22:38', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:55:19";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:25:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:25:19', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 10:55:24";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:25:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:25:24', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:00:00";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:30:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:30:00', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:00:12";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:30:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:30:12', '4', 'addsellBill', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:00:40";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:30:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:30:40', '4', '', '41.233.78.177', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:00:43";
UPDATE user SET loginip = "41.233.78.177", lastactivetime = "2022-08-20 14:30:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:30:43', '4', 'addsellBill', '41.233.78.177', '', '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 < "2022-08-20 11:04:14";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 14:34:14", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 14:34:14', '5', '', '197.55.113.160', '', '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 < "2022-08-20 11:04:14";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:04:32";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 14:34:32", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:34:33', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE userid = 6;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:08:44";
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 < "2022-08-20 11:08:48";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:38:48", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 14:38:48', '6', '', '156.217.194.191', '', '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 < "2022-08-20 11: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 < "2022-08-20 11:08:50";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:38:50", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:38:50', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:09:39";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:39:39", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:39:39', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:10:56";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:40:56", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:40:56', '6', 'addAndRetuen', '156.217.194.191', '', '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 06300d5da9e7d9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(179,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2022-08-20 14:38:50', '06300d5da9e7d9', '179', '1205.00', '1355', '0', '1', '650', '650', '500', '150', '4', '2022-08-20 14:40:56', '', '6', '0', 'ام جنين مجل روح', '4', '1', '3', '0', 'ام جنين مجل روح', '3' ,'0','','','','','-1','0','0','0','0','0','650','0','','0','0','500','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '1355', userid = '6' WHERE clientid = '179';
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 ('179','1205.00','150','0','اضافة فاتورة مبيعات','7808', '1355', '2022-08-20 14:40:56', '6', 'sellbillController.php', 'اضافة فاتورة مبيعات', '650', '0', null, '0', null, null,'', '0','1','1','150','1');
UPDATE client SET  inUse = 0 where clientid = 179;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9112;
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 ('210','01125', '7808', '1', '1125', '1', '220.00', '220', '0', '', '0', '2022-08-20 14:40:56', '1125', '0.00', '0', '4','0','','','0','0','0','0','0','0','0','0','','9112-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23423;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1125, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 (4, '2022-08-20', 220, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '6', storedetaildate = '2022-08-20 14:40:56' WHERE storedetailid = '4108';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '4', '1', '1', '7808', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24.00', '23', '6', '2022-08-20 14:40:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9042;
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 ('220','01074', '7808', '1', '1074', '1', '220.00', '220', '0', '', '0', '2022-08-20 14:40:56', '1074', '0.00', '0', '4','0','','','0','0','0','0','0','0','0','0','','9042-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23424;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 220, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 (4, '2022-08-20', 220, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '6', storedetaildate = '2022-08-20 14:40:56' WHERE storedetailid = '3805';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '4', '1', '1', '7808', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24.00', '23', '6', '2022-08-20 14:40:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9110;
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 ('200','01123', '7808', '1', '1123', '1', '210.00', '210', '0', '', '0', '2022-08-20 14:40:56', '1123', '0.00', '0', '4','0','','','0','0','0','0','0','0','0','0','','9110-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23425;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1123, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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 (4, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '6', storedetaildate = '2022-08-20 14:40:56' WHERE storedetailid = '4107';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '4', '1', '1', '7808', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '19', '6', '2022-08-20 14:40:56','0','0');
UPDATE save SET  savecurrentvalue = '1705',  userid = '6' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1205.00','500', '0', '4', 'اضافة فاتورة مبيعات', '7808', '1705', '2022-08-20 14:40:56', '6',  'sellbillController.php','179','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 650, 630, 630
                    , 630, 630, 630, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , 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 (179, '2022-08-20', 650, 630, 630
                    , 630, 630, 630, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , 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, 650, 630, 630
                    , 630, 630, 630, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+650, netSellCostBuyPrice = netSellCostBuyPrice+630
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+630
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+630
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+630
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300d5da9e7d9 and sellbillId = 7808 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:10:56";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:40:57", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:40:57', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:11:17";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:41:17", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:41:17', '6', 'addAndRetuen', '156.217.194.191', '', '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 06300d60c003b8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(179,@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 ('2022-08-20 14:39:40', '06300d60c003b8', '179', '1355.00', '1355', '0', '1', '185', '185', '185', '0', '4', '2022-08-20 14:41:17', '', '6', '0', 'ام جنين مجل روح','4', '1', '5', '0', 'ام جنين مجل روح', '1', '0', '', '','','','-1','0','0','0','','0','185','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1355', userid = '6' WHERE clientid = '179';
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 ('179','1355.00','0','1','اضافة فاتورة مردوات مبيعات','2798', '1355', '2022-08-20 14:41:17', '6', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '185', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE client SET  inUse = 0 where clientid = 179;
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 ('180.00', '00298', '2798', '1', '298', '1', '185.00', '185', '0', '', '0', '0', '298', '0.00', '0','4','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
                where returnsellbilldetailid = 6084;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (298, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 180, 180, 180
                    , 180, 180, 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+185, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                            , 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 (4, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 180, 180, 180
                    , 180, 180, 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+185, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '6', storedetaildate = '2022-08-20 14:41:17' WHERE storedetailid = '757';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('298', '4', '1', '0', '2798', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6.00', '7', '6', '2022-08-20 14:41:17','0','0');
UPDATE save SET  savecurrentvalue = '1520',  userid = '6' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1705.00','-185', '1', '4', 'اضافة فاتورة مردوات مبيعات', '2798', '1520', '2022-08-20 14:41:17', '6',  'returnsellbillController.php','179','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 180, 180, 180
                    , 180, 180, 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+185, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (179, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 185, 180, 180, 180
                    , 180, 180, 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+185, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -185, -180, -180
                    , -180, -180, -180, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-185, netSellCostBuyPrice = netSellCostBuyPrice+-180
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-180
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-180
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-180
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-180
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300d60c003b8 and sellbillId = 2798 and returnsellbillId = 2798
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:11:17";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:41:18", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 14:41:18', '6', 'addsellBill', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:11:20";
UPDATE user SET loginip = "156.217.194.191", lastactivetime = "2022-08-20 14:41:20", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 14:41:20', '6', '', '156.217.194.191', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:52:16";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 15:22:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 15:22:16', '4', '', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:52:32";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 15:22:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 15:22:32', '4', 'add', '102.41.163.155', '', '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 =11798
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(130,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '2000' , clientdate = '2022-08-20 15:22:32', userid = '4' WHERE clientid = '130';
UPDATE client SET  inUse = 0 where clientid = 130;
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 ('130','2625.00','625','1','ايصال تحصيل (( قبض من عميل ))','11798', '2000', '2022-08-20 15:22:17', '4', 'clientPayedDeptController.php', '   ', '625', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '4310',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3685.00','625', '0', '7', 'ايصال تحصيل (( قبض من عميل ))', '11798', '4310', '2022-08-20 15:22:32', '4',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '625', '625', '2022-08-20', '4', '0', '0', '2022-08-20 15:22:32','اضافة ايصال سداد للعميل محمد مشعل','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4457', '141', '625', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-887125', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4457', '206', '625', '','0');
UPDATE accountstree SET name = 'محمد مشعل', customName = 'محمد مشعل', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '4', mydate = '2022-03-10', itemtype2 = '1', theValue = '-5635', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '206';
UPDATE clientdebtchange SET clientid = '130', clientdebtchangebefore = '2625.00', clientdebtchangeamount = '625.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '11798', clientdebtchangeafter = '2000.00', clientdebtchangedate = '2022-08-20 15:22:17', userid = '4', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '625.00',discount='', reciptid=null, dailyentryid = '4457',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '11798';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:52:33";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 15:22:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 15:22:33', '4', 'editprint2', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:52:42";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 15:22:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 15:22:42', '4', 'addsellBill', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 11:58:31";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 15:28:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 15:28:31', '4', '', '102.41.163.155', '', '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 < "2022-08-20 12:22:59";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 15:52:59", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 15:52:59', '5', '', '197.55.113.160', '', '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 < "2022-08-20 12:22:59";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:23:02";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 15:53:02", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 15:53:02', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:38:39";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 16:08:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:08:39', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:43:05";
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 < "2022-08-20 12:43:27";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:13:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 16:13:27', '1', '', '156.210.34.51', '', '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 < "2022-08-20 12:43:27";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:43:49";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:13:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-08-20 16:13:49', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:44:03";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:14:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 16:14:04', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:44:56";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:14:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 16:14:56', '1', 'add', '156.210.34.51', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '6', '-1', '0', '1740.00', '55', '1795', '', '0', '2022-08-20 16:14:56', '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', '', '55', '1', ' خصم معالجة عجز  / ', '169', '-55', '2022-08-20', '1', 'supplierPayedDeptController.php', '', '0','6', '0','1','1','55','1');
UPDATE supplier SET  suppliercurrentDebt = '-55', userid = '1', supplierdate = '2022-08-20'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '55.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '169', supplierdebtchangeafter = '-55.00', supplierdebtchangedate = '2022-08-20 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '6',currencyId='1',conversionFactor='1',payedInCurrency='55',saveConversionFactor='1' WHERE supplierdebtchangeid = '544';
UPDATE save SET  savecurrentvalue = '1795',  userid = '1' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1740.00','55', '0', '6', 'تسوية خزنة بالإضافة', '-1', '1795', '2022-08-20 16:14:56', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '12649' WHERE savedailyid = '12649';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '55', '55', '2022-08-20', '1', '0', '0', '2022-08-20 16:14:56','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4458', '140', '55', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-554865', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4458', '27', '55', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-51604', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:44:56";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:14:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 16:14:56', '1', 'sucess', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:44:58";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:14:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 16:14:58', '1', 'show', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:45:01";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:15:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 16:15:01', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:45:21";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:15:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 16:15:22', '1', 'show', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:46:55";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 16:16:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:16:56', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:55:47";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:25:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:25:47', '4', 'addsellBill', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:56:20";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:26:20", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:26:20', '4', 'addAndRetuen', '102.41.163.155', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06300eeeb37496
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 16:25:47', '06300eeeb37496', '1', '0.00', '0', '0', '1', '210', '210', '-210', '0', '7', '2022-08-20 16:26:21', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-210','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','اضافة فاتورة مردوات مبيعات','2799', '0', '2022-08-20 16:26:21', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '210', '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 ('200.00', '01118', '2799', '1', '1118', '1', '210', '210', '0', '', '0', '0', '1118', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where returnsellbilldetailid = 6085;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1118, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 200, 200, 200
                    , 200, 200, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 200, 200, 200
                    , 200, 200, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '4', storedetaildate = '2022-08-20 16:26:21' WHERE storedetailid = '4079';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1118', '7', '1', '0', '2799', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-1.00', '0', '4', '2022-08-20 16:26:21','0','0');
UPDATE save SET  savecurrentvalue = '4100',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4310.00','210', '1', '7', 'اضافة فاتورة مردوات مبيعات', '2799', '4100', '2022-08-20 16:26:21', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 200, 200, 200
                    , 200, 200, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 200, 200, 200
                    , 200, 200, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -210, -200, -200
                    , -200, -200, -200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-210, netSellCostBuyPrice = netSellCostBuyPrice+-200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06300eeeb37496 and sellbillId = 2799 and returnsellbillId = 2799
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:56:21";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:26:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:26:21', '4', 'addsellBill', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:56:26";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:26:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 16:26:26', '4', '', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 12:56:32";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:26:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:26:33', '4', 'addsellBill', '102.41.163.155', '', '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 < "2022-08-20 13:08:43";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 16:38:44", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 16:38:44', '5', '', '197.55.113.160', '', '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 < "2022-08-20 13:08:44";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 13:08:46";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 16:38:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 16:38:46', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 13:09:11";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 16:39:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 16:39:11', '4', '', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 13:56:47";
UPDATE user SET loginip = "102.41.163.155", lastactivetime = "2022-08-20 17:26:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 17:26:47', '4', 'addsellBill', '102.41.163.155', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:02:35";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 17:32:35", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 17:32:35', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:03:17";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 17:33:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 17:33:17', '7', 'add', '197.192.206.104', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('3', 'ايجار الشقه والمياه والغاز', '', '1720', '2022-08-20', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '925',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2645.00','1720', '1', '5', 'إضافة مصروف', '1664', '925', '2022-08-20 17:33:17', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1720', '1720', '2022-08-20', '7', '0', '0', '2022-08-20 17:33:17','اضافة اسم مصروف( ايجار الشقه والمياه والغاز )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4459', '146', '1720', '','0');
UPDATE accountstree SET name = 'ايجار', customName = 'ايجار', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '178335', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '146';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4459', '139', '1720', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1008339', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '3', expensesname = 'ايجار الشقه والمياه والغاز', expensesdetails = '', expensesValue = '1720.00', expensesdate = '2022-08-20', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '4459', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1664';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:03:17";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 17:33:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 17:33:17', '7', 'sucess', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:03:29";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 17:33:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 17:33:29', '7', 'show', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:03:33";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 17:33:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 17:33:33', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:08:29";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:38:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 17:38:29', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:12:19";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:42:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 17:42:19', '1', '', '156.210.34.51', '', '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 < "2022-08-20 14:12:20";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:12:32";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:42:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 17:42:32', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:13:08";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:43:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 17:43:08', '1', 'add', '156.210.34.51', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '4', '-1', '0', '1520.00', '100', '1620', '', '0', '2022-08-20 17:43:08', '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', '', '100', '1', ' خصم معالجة عجز  / ', '170', '-100', '2022-08-20', '1', 'supplierPayedDeptController.php', '', '0','4', '0','1','1','100','1');
UPDATE supplier SET  suppliercurrentDebt = '-100', userid = '1', supplierdate = '2022-08-20'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '100.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '170', supplierdebtchangeafter = '-100.00', supplierdebtchangedate = '2022-08-20 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '4',currencyId='1',conversionFactor='1',payedInCurrency='100',saveConversionFactor='1' WHERE supplierdebtchangeid = '545';
UPDATE save SET  savecurrentvalue = '1620',  userid = '1' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1520.00','100', '0', '4', 'تسوية خزنة بالإضافة', '-1', '1620', '2022-08-20 17:43:08', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '12652' WHERE savedailyid = '12652';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2022-08-20', '1', '0', '0', '2022-08-20 17:43:08','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4460', '138', '100', '','0');
UPDATE accountstree SET name = 'خزينة محل المحلة', customName = 'خزينة محل المحلة', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-03-27', itemtype2 = '1', theValue = '-460220', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '138';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4460', '27', '100', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-51704', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:13:09";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:43:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 17:43:09', '1', 'sucess', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:13:11";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:43:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2022-08-20 17:43:11', '1', 'show', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:14:42";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:44:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 17:44:42', '1', 'add', '156.210.34.51', '', '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(1059,3,5,647,2,'2022-08-20',1,0, '' ,0,0,0,0,0,'2022-08-20 17:44:42',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '43', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2023';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-07-06', 3, 647, 0, 0
                    , 280.00, 2, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2022-07-06*280.00," WHERE transferproductid = 4521;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '3', '2', '1', '4521', 'تحويل منتجات من المخزن', 'storemovementController.php', '45.00', '43', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2268';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-07-06', 5, 647, 0, 0
                    , 280.00, 2, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '5', '2', '0', '4521', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '29.00', '31', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '25', '2', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '1627';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-04-11', 3, 25, 0, 0
                    , 170.00, 2, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2022-04-11*170.00," WHERE transferproductid = 4522;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('25', '3', '2', '1', '4522', 'تحويل منتجات من المخزن', 'storemovementController.php', '21.00', '19', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4089';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-04-11', 5, 25, 0, 0
                    , 170.00, 2, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('25', '5', '2', '0', '4522', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '4', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '163', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '1418';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 3, 163, 0, 0
                    , 165.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2021-11-08*165.00," WHERE transferproductid = 4523;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('163', '3', '1', '1', '4523', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '14', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '843';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 5, 163, 0, 0
                    , 165.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('163', '5', '1', '0', '4523', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '8.00', '9', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '6', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '1385';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 3, 6, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2021-11-08*145.00," WHERE transferproductid = 4524;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('6', '3', '1', '1', '4524', 'تحويل منتجات من المخزن', 'storemovementController.php', '32.00', '31', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('6', '5', '1', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 5, 6, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('6', '5', '1', '0', '4524', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '760', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2195';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 3, 760, 0, 0
                    , 215.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-02-24*215.00," WHERE transferproductid = 4525;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('760', '3', '1', '1', '4525', 'تحويل منتجات من المخزن', 'storemovementController.php', '3.00', '2', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2359';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 5, 760, 0, 0
                    , 215.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('760', '5', '1', '0', '4525', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '-1.00', '0', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '747', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2219';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-03-29', 3, 747, 0, 0
                    , 195.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-03-29*195.00," WHERE transferproductid = 4526;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('747', '3', '1', '1', '4526', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '7', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '-6', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2284';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-03-29', 5, 747, 0, 0
                    , 195.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('747', '5', '1', '0', '4526', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '-7.00', '-6', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '37', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '25', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '1593';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 3, 37, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-02-24*145.00," WHERE transferproductid = 4527;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('37', '3', '1', '1', '4527', 'تحويل منتجات من المخزن', 'storemovementController.php', '26.00', '25', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('37', '5', '1', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 5, 37, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('37', '5', '1', '0', '4527', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '39', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2203';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 3, 39, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-02-24*145.00," WHERE transferproductid = 4528;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('39', '3', '1', '1', '4528', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '19', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4090';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 5, 39, 0, 0
                    , 145.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('39', '5', '1', '0', '4528', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '1', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '886', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3358';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-04-20', 3, 886, 0, 0
                    , 180.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-04-20*180.00," WHERE transferproductid = 4529;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('886', '3', '1', '1', '4529', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '14', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3725';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-04-20', 5, 886, 0, 0
                    , 180.00, 1, 0, 0, 1, '2022-08-20 17:44:42')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:42' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('886', '5', '1', '0', '4529', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '2', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '181', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:42',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '42', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '1382';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 3, 181, 0, 0
                    , 195.00, 1, 0, 0, 1, '2022-08-20 17:44:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:43' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2021-11-08*195.00," WHERE transferproductid = 4530;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('181', '3', '1', '1', '4530', 'تحويل منتجات من المخزن', 'storemovementController.php', '43.00', '42', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2258';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-08', 5, 181, 0, 0
                    , 195.00, 1, 0, 0, 1, '2022-08-20 17:44:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:43' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('181', '5', '1', '0', '4530', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '11.00', '12', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('3', '5', '1051', '1', '2022-08-20', '1', '0','1059',null,null,'2022-08-20 17:44:43',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3675';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-05-30', 3, 1051, 0, 0
                    , 170.00, 1, 0, 0, 1, '2022-08-20 17:44:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:43' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-05-30*170.00," WHERE transferproductid = 4531;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1051', '3', '1', '1', '4531', 'تحويل منتجات من المخزن', 'storemovementController.php', '5.00', '4', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3730';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-05-30', 5, 1051, 0, 0
                    , 170.00, 1, 0, 0, 1, '2022-08-20 17:44:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 17:44:43' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1051', '5', '1', '0', '4531', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '4.00', '5', '1', '2022-08-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:14:43";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:44:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 17:44:43', '1', 'editshow', '156.210.34.51', '', '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 < "2022-08-20 14:17:01";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 17:47:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 17:47:02', '1', '', '156.210.34.51', '', '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 < "2022-08-20 14:17:02";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE userid = 6;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:41:27";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:11:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 18:11:28', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:42:23";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:12:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 18:12:23', '1', 'add', '156.210.34.51', '', '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(1060,8,7,572,24,'2022-08-20',1,0, '' ,0,0,0,0,0,'2022-08-20 18:12:23',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2049';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-22', 8, 572, 0, 0
                    , 210.00, 4, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-4, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 8, 572, 0, 0
                    , 210.00, 20, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-20, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "4*2022-02-22*210.00,20*2022-02-24*210.00," WHERE transferproductid = 4532;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '8', '24', '1', '4532', 'تحويل منتجات من المخزن', 'storemovementController.php', '55.00', '31', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2056';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-22', 7, 572, 0, 0
                    , 210.00, 4, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+4, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 7, 572, 0, 0
                    , 210.00, 20, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '7', '24', '0', '4532', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '5.00', '29', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('8', '7', '666', '24', '2022-08-20', '1', '0','1060',null,null,'2022-08-20 18:12:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '37', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2032';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-22', 8, 666, 0, 0
                    , 200.00, 6, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-6, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 8, 666, 0, 0
                    , 200.00, 18, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2022-02-22*200.00,18*2022-02-24*200.00," WHERE transferproductid = 4533;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('666', '8', '24', '1', '4533', 'تحويل منتجات من المخزن', 'storemovementController.php', '61.00', '37', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '53', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '2070';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-22', 7, 666, 0, 0
                    , 200.00, 6, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-24', 7, 666, 0, 0
                    , 200.00, 18, 0, 0, 1, '2022-08-20 18:12:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 18:12:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('666', '7', '24', '0', '4533', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '29.00', '53', '1', '2022-08-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:42:23";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:12:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 18:12:24', '1', 'editshow', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:43:03";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:13:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 18:13:03', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:47:44";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:17:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('saveController.php', '2022-08-20 18:17:44', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 14:47:50";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 18:17:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-08-20 18:17:50', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:26:32";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 18:56:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 18:56:32', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:28:50";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 18:58:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 18:58:50', '7', 'addAndRetuen', '197.192.206.104', '', '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 063011240a2e46
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(132,@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 ('2022-08-20 18:56:32', '063011240a2e46', '132', '0.00', '-640', '0', '1', '640', '640', '0', '-640', '5', '2022-08-20 18:58:50', '', '7', '0', 'ام ساندي اسكندريه','5', '1', '5', '0', 'ام ساندي اسكندريه', '3', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-640', userid = '7' WHERE clientid = '132';
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 ('132','0.00','640','1','اضافة فاتورة مردوات مبيعات','2800', '-640', '2022-08-20 18:58:50', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '640', '0', null, '0', null, null,'', '0','1','1','640','1');
UPDATE client SET  inUse = 0 where clientid = 132;
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 ('190.00', '01059', '2800', '1', '1059', '1', '200.00', '200', '0', '', '0', '0', '1059', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
                where returnsellbilldetailid = 6086;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1059, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 190, 190, 190
                    , 190, 190, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 190, 190, 190
                    , 190, 190, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '7', storedetaildate = '2022-08-20 18:58:50' WHERE storedetailid = '3787';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1059', '5', '1', '0', '2800', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '10.00', '11', '7', '2022-08-20 18:58:50','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 ('200.00', '01047', '2800', '1', '1047', '1', '200.00', '200', '0', '', '0', '0', '1047', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where returnsellbilldetailid = 6087;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1047, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 200, 200, 200
                    , 200, 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 200, 200, 200
                    , 200, 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '7', storedetaildate = '2022-08-20 18:58:50' WHERE storedetailid = '3656';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1047', '5', '1', '0', '2800', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '7.00', '8', '7', '2022-08-20 18:58:50','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 ('230.00', '01113', '2800', '1', '1113', '1', '240.00', '240', '0', '', '0', '0', '1113', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
                where returnsellbilldetailid = 6088;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1113, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 240, 230, 230, 230
                    , 230, 230, 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+240, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 240, 230, 230, 230
                    , 230, 230, 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+240, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '22', userid = '7', storedetaildate = '2022-08-20 18:58:50' WHERE storedetailid = '4038';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1113', '5', '1', '0', '2800', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '21.00', '22', '7', '2022-08-20 18:58:50','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 640, 620, 620, 620
                    , 620, 620, 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+640, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (132, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 640, 620, 620, 620
                    , 620, 620, 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+640, returnSellCostBuyPrice = returnSellCostBuyPrice+620, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+620
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+620, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+620
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+620
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -640, -620, -620
                    , -620, -620, -620, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-640, netSellCostBuyPrice = netSellCostBuyPrice+-620
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-620
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-620
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-620
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-620
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063011240a2e46 and sellbillId = 2800 and returnsellbillId = 2800
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:28:50";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 18:58:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 18:58:50', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:30:03";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 19:00:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 19:00:03', '7', 'addsellBill', '197.192.206.104', '', '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 < "2022-08-20 15:35:18";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:18", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 19:05:18', '5', '', '197.55.113.160', '', '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 < "2022-08-20 15:35:18";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:35:20";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:20", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 19:05:20', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:35:49";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 19:05:49', '5', 'addAndRetuen', '197.55.113.160', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630114511a27e
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 19:05:21', '0630114511a27e', '1', '0.00', '0', '0', '1', '210', '210', '210', '0', '3', '2022-08-20 19:05:49', '', '5', '0', 'نقدي', '3', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','210','0','','0','0','210','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '5' 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','اضافة فاتورة مبيعات','7809', '0', '2022-08-20 19:05:49', '5', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8662;
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 ('200','00123', '7809', '1', '123', '1', '210.00', '210', '0', '', '1', '2022-08-20 19:05:49', '123', '0.00', '0', '3','0','','','0','0','0','0','0','0','1','0','','8662-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23426;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (123, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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 (3, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '5', storedetaildate = '2022-08-20 19:05:49' WHERE storedetailid = '2015';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('123', '3', '1', '1', '7809', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '5', '2022-08-20 19:05:49','0','0');
UPDATE save SET  savecurrentvalue = '39595',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('39385.00','210', '0', '3', 'اضافة فاتورة مبيعات', '7809', '39595', '2022-08-20 19:05:49', '5',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 210, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, 210, 200, 200
                    , 200, 200, 200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, netSellCostBuyPrice = netSellCostBuyPrice+200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630114511a27e and sellbillId = 7809 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:35:49";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 19:05:49', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:35:51";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:52", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 19:05:52', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:35:55";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:05:55", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 19:05:55', '5', 'showDetail', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:36:06";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:06:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 19:06:06', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 15:36:12";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 19:06:12", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 19:06:12', '5', 'showDetail', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:12:04";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:42:04", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 20:42:04', '8', '', '154.176.79.137', '', '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 < "2022-08-20 17:12: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 < "2022-08-20 17:12:28";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:42:28", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:42:28', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:14:53";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:44:53", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:44:53', '8', 'addAndRetuen', '154.176.79.137', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012b14b7f89
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:42:28', '063012b14b7f89', '1', '0.00', '0', '0', '1', '2715', '2715', '2715', '0', '6', '2022-08-20 20:44:53', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '10' ,'0','','','','','-1','0','0','0','0','0','2715','0','','0','0','2715','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','اضافة فاتورة مبيعات','7810', '0', '2022-08-20 20:44:53', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2715', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8508;
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 ('280','00647', '7810', '1', '647', '1', '370', '370', '0', '', '1', '2022-08-20 20:44:53', '647', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8508-1,');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 304.38, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 304.38
                where sellbilldetailid = 23427;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (647, '2022-08-20', 370, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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, '2022-08-20', 370, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '33', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '2238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34.00', '33', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8132;
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 ('220','01074', '7810', '1', '1074', '1', '270', '270', '0', '', '1', '2022-08-20 20:44:53', '1074', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8132-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23428;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 = '51', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '3932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52.00', '51', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8132;
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 ('220','01074', '7810', '1', '1074', '1', '270', '270', '0', '', '1', '2022-08-20 20:44:53', '1074', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8132-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23429;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 = '50', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '3932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '51.00', '50', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8612;
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 ('230','01113', '7810', '1', '1113', '1', '280', '280', '0', '', '1', '2022-08-20 20:44:53', '1113', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8612-1,');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
                where sellbilldetailid = 23430;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1113, '2022-08-20', 280, 230, 230
                    , 230, 230, 230, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , 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, '2022-08-20', 280, 230, 230
                    , 230, 230, 230, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '4012';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1113', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '8', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8508;
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 ('280','00647', '7810', '1', '647', '1', '370', '370', '0', '', '1', '2022-08-20 20:44:53', '647', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8508-1,');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 304.38, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 304.38
                where sellbilldetailid = 23431;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (647, '2022-08-20', 370, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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, '2022-08-20', 370, 320, 280
                    , 304.38, 280, 304.38, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304.38
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304.38
                            , 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 = '32', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '2238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33.00', '32', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8132;
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 ('220','01074', '7810', '1', '1074', '1', '270', '270', '0', '', '1', '2022-08-20 20:44:53', '1074', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','8132-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23432;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '49', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '3932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '50.00', '49', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 5214;
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 ('145','00422', '7810', '1', '422', '1', '195', '195', '0', '', '1', '2022-08-20 20:44:53', '422', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','5214-1,');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
                where sellbilldetailid = 23433;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (422, '2022-08-20', 195, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , 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, '2022-08-20', 195, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '5', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('422', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 6384;
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 ('170','00643', '7810', '1', '643', '1', '205', '205', '0', '', '1', '2022-08-20 20:44:53', '643', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','6384-1,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 23434;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (643, '2022-08-20', 205, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 205, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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 = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '2711';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('643', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 4262;
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 ('195','00835', '7810', '1', '835', '1', '235', '235', '0', '', '1', '2022-08-20 20:44:53', '835', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','4262-1,');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
                where sellbilldetailid = 23435;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (835, '2022-08-20', 235, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , 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, '2022-08-20', 235, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , 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 = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '2640';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('835', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '8', '2022-08-20 20:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7482;
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 ('200','01042', '7810', '1', '1042', '1', '250', '250', '0', '', '1', '2022-08-20 20:44:53', '1042', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','7482-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23436;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1042, '2022-08-20', 250, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 250, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '8', storedetaildate = '2022-08-20 20:44:53' WHERE storedetailid = '3667';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1042', '6', '1', '1', '7810', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '20', '8', '2022-08-20 20:44:53','0','0');
UPDATE save SET  savecurrentvalue = '4510',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1795.00','2715', '0', '6', 'اضافة فاتورة مبيعات', '7810', '4510', '2022-08-20 20:44:53', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 2715, 2240, 2160
                    , 2208.76, 2160, 2208.76, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2715, sellCostBuyPrice =sellCostBuyPrice+2240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2208.76
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2208.76
                            , 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, '2022-08-20', 2715, 2240, 2160
                    , 2208.76, 2160, 2208.76, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2715, sellCostBuyPrice =sellCostBuyPrice+2240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2208.76
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2208.76
                            , 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, 2715, 2240, 2160
                    , 2208.76, 2160, 2208.76, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2715, netSellCostBuyPrice = netSellCostBuyPrice+2240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2160
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2208.76
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2160
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2208.76
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012b14b7f89 and sellbillId = 7810 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:14:54";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:44:54", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:44:54', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:08";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:08", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:08', '8', 'addAndRetuen', '154.176.79.137', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012ba6759a6
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:44:54', '063012ba6759a6', '1', '0.00', '0', '0', '1', '270', '270', '270', '0', '6', '2022-08-20 20:45:08', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','270','0','','0','0','270','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','اضافة فاتورة مبيعات','7811', '0', '2022-08-20 20:45:08', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '270', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9046;
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 ('220','01074', '7811', '1', '1074', '1', '270', '270', '0', '', '1', '2022-08-20 20:45:08', '1074', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','9046-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23437;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 = '48', userid = '8', storedetaildate = '2022-08-20 20:45:08' WHERE storedetailid = '3932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '6', '1', '1', '7811', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49.00', '48', '8', '2022-08-20 20:45:08','0','0');
UPDATE save SET  savecurrentvalue = '4780',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4510.00','270', '0', '6', 'اضافة فاتورة مبيعات', '7811', '4780', '2022-08-20 20:45:08', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, 270, 220, 220
                    , 220, 220, 220, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+270, netSellCostBuyPrice = netSellCostBuyPrice+220
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+220
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+220
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+220
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+220
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012ba6759a6 and sellbillId = 7811 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:09";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:09", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:09', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:12";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:13", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:13', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:14";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:14", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:14', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:24";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:24", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:24', '8', 'addAndRetuen', '154.176.79.137', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012bbb0cc6f
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:45:15', '063012bbb0cc6f', '1', '0.00', '0', '0', '1', '280', '280', '-280', '0', '6', '2022-08-20 20:45:24', '', '8', '0', 'نقدي','6', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-280','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','1','اضافة فاتورة مردوات مبيعات','2801', '0', '2022-08-20 20:45:24', '8', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '280', '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 ('230.00', '01113', '2801', '1', '1113', '1', '280', '280', '0', '', '1', '0', '1113', '0.00', '0','6','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
                where returnsellbilldetailid = 6089;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1113, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 230, 230, 230
                    , 230, 230, 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+280, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 230, 230, 230
                    , 230, 230, 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+280, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '8', storedetaildate = '2022-08-20 20:45:24' WHERE storedetailid = '4012';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1113', '6', '1', '0', '2801', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '8.00', '9', '8', '2022-08-20 20:45:24','0','0');
UPDATE save SET  savecurrentvalue = '4500',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4780.00','280', '1', '6', 'اضافة فاتورة مردوات مبيعات', '2801', '4500', '2022-08-20 20:45:24', '8',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 230, 230, 230
                    , 230, 230, 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+280, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 280, 230, 230, 230
                    , 230, 230, 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+280, returnSellCostBuyPrice = returnSellCostBuyPrice+230, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+230
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+230, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+230
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+230
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -280, -230, -230
                    , -230, -230, -230, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-280, netSellCostBuyPrice = netSellCostBuyPrice+-230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012bbb0cc6f and sellbillId = 2801 and returnsellbillId = 2801
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:15:25";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:45:25", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:45:25', '8', 'addsellBill', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:16:22";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:46:22", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 20:46:22', '8', '', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:21:44";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:51:44", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:51:44', '8', '', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:21:55";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:51:55", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:51:55', '8', 'add', '154.176.79.137', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جهاد', '', '1000', '2022-08-20', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3500',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4500.00','1000', '1', '6', 'إضافة مصروف', '1665', '3500', '2022-08-20 20:51:55', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1000', '1000', '2022-08-20', '8', '0', '0', '2022-08-20 20:51:55','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4461', '160', '1000', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-673260', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4461', '140', '1000', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-555865', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جهاد', expensesdetails = '', expensesValue = '1000.00', expensesdate = '2022-08-20', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '4461', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1665';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:21:55";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:51:55", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:51:55', '8', 'sucess', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:21:57";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:51:57", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:51:57', '8', 'show', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:22:00";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:52:00", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:52:00', '8', '', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:22:07";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:52:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:52:07', '8', 'add', '154.176.79.137', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'فطار', '', '10', '2022-08-20', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3490',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3500.00','10', '1', '6', 'إضافة مصروف', '1666', '3490', '2022-08-20 20:52:07', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '10', '10', '2022-08-20', '8', '0', '0', '2022-08-20 20:52:07','اضافة اسم مصروف( فطار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4462', '160', '10', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-673270', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4462', '140', '10', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-555875', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'فطار', expensesdetails = '', expensesValue = '10.00', expensesdate = '2022-08-20', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '4462', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1666';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:22:08";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:52:08", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:52:08', '8', 'sucess', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:22:09";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:52:10", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-08-20 20:52:10', '8', 'show', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:22:12";
UPDATE user SET loginip = "154.176.79.137", lastactivetime = "2022-08-20 20:52:12", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 20:52:12', '8', '', '154.176.79.137', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:27:40";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:57:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:57:40', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:28:00";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:58:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:58:00', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012ea4cf532
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:57:40', '063012ea4cf532', '1', '0.00', '0', '10', '1', '200', '190', '190', '0', '5', '2022-08-20 20:58:01', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','190','0','','0','0','190','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','اضافة فاتورة مبيعات','7812', '0', '2022-08-20 20:58:01', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '190', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 3344;
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 ('160','00436', '7812', '1', '436', '1', '200', '200', '0', '', '1', '2022-08-20 20:58:01', '436', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','3344-1,');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 23438;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (436, '2022-08-20', 190, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, '2022-08-20', 190, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2022-08-20 20:58:01' WHERE storedetailid = '1638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('436', '5', '1', '1', '7812', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '7', '2022-08-20 20:58:01','0','0');
UPDATE save SET  savecurrentvalue = '1115',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('925.00','190', '0', '5', 'اضافة فاتورة مبيعات', '7812', '1115', '2022-08-20 20:58:01', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 190, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, '2022-08-20', 190, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, 190, 160, 160
                    , 160, 160, 160, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+190, netSellCostBuyPrice = netSellCostBuyPrice+160
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+160
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+160
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+160
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+160
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012ea4cf532 and sellbillId = 7812 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:28:01";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:58:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:58:01', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:28:32";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:58:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:58:32', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012eb9e21ae
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:58:01', '063012eb9e21ae', '1', '0.00', '0', '0', '1', '255', '255', '255', '0', '5', '2022-08-20 20:58:32', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','255','0','','0','0','255','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','اضافة فاتورة مبيعات','7813', '0', '2022-08-20 20:58:32', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '255', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8670;
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 ('255','01112', '7813', '1', '1112', '1', '255.00', '255', '0', '', '0', '2022-08-20 20:58:32', '1112', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8670-1,');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
                where sellbilldetailid = 23439;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1112, '2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , 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, '2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '7', storedetaildate = '2022-08-20 20:58:32' WHERE storedetailid = '4037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1112', '5', '1', '1', '7813', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '20', '7', '2022-08-20 20:58:32','0','0');
UPDATE save SET  savecurrentvalue = '1370',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1115.00','255', '0', '5', 'اضافة فاتورة مبيعات', '7813', '1370', '2022-08-20 20:58:32', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , 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, '2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , 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, 255, 255, 255
                    , 255, 255, 255, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+255, netSellCostBuyPrice = netSellCostBuyPrice+255
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+255
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+255
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+255
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+255
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012eb9e21ae and sellbillId = 7813 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:28:32";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:58:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:58:32', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:29:32";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:59:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:59:32', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012ed90541f
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:58:33', '063012ed90541f', '1', '0.00', '0', '0', '1', '690', '690', '690', '0', '5', '2022-08-20 20:59:32', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','690','0','','0','0','690','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','اضافة فاتورة مبيعات','7814', '0', '2022-08-20 20:59:32', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '690', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8454;
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 ('160','00436', '7814', '1', '436', '1', '170', '170', '0', '', '0', '2022-08-20 20:59:32', '436', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8454-1,');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 23440;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (436, '2022-08-20', 170, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, '2022-08-20', 170, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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 = '2022-08-20 20:59:32' WHERE storedetailid = '1638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('436', '5', '1', '1', '7814', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '7', '2022-08-20 20:59:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7748;
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 ('265','01062', '7814', '1', '1062', '1', '265', '265', '0', '', '0', '2022-08-20 20:59:32', '1062', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','7748-1,');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
                where sellbilldetailid = 23441;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1062, '2022-08-20', 265, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , 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, '2022-08-20', 265, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '33', userid = '7', storedetaildate = '2022-08-20 20:59:32' WHERE storedetailid = '3765';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '5', '1', '1', '7814', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34.00', '33', '7', '2022-08-20 20:59:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8670;
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 ('255','01112', '7814', '1', '1112', '1', '255', '255', '0', '', '0', '2022-08-20 20:59:32', '1112', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8670-1,');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
                where sellbilldetailid = 23442;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1112, '2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , 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, '2022-08-20', 255, 255, 255
                    , 255, 255, 255, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '7', storedetaildate = '2022-08-20 20:59:32' WHERE storedetailid = '4037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1112', '5', '1', '1', '7814', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '19', '7', '2022-08-20 20:59:32','0','0');
UPDATE save SET  savecurrentvalue = '2060',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1370.00','690', '0', '5', 'اضافة فاتورة مبيعات', '7814', '2060', '2022-08-20 20:59:32', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 690, 680, 680
                    , 680, 680, 680, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+690, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+680
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+680
                            , 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, '2022-08-20', 690, 680, 680
                    , 680, 680, 680, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+690, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+680
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+680
                            , 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, 690, 680, 680
                    , 680, 680, 680, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+690, netSellCostBuyPrice = netSellCostBuyPrice+680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+680
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+680
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+680
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+680
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012ed90541f and sellbillId = 7814 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:29:33";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:59:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:59:33', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:29:37";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 20:59:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 20:59:37', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:30:29";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:00:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:00:29', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012f1982a6f
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 20:59:37', '063012f1982a6f', '1', '0.00', '0', '10', '1', '600', '590', '-590', '0', '5', '2022-08-20 21:00:29', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '3', '0', '', '','','','-1','0','0','0','','0','-590','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','اضافة فاتورة مردوات مبيعات','2802', '0', '2022-08-20 21:00:29', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '590', '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 ('220.00', '01074', '2802', '1', '1074', '1', '230.00', '230', '0', '', '2', '0', '1074', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where returnsellbilldetailid = 6090;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 233.833333333, 220, 220, 220
                    , 220, 220, 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+233.833333333, returnSellCostBuyPrice = returnSellCostBuyPrice+220, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+220
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+220, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+220
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 233.833333333, 220, 220, 220
                    , 220, 220, 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+233.833333333, returnSellCostBuyPrice = returnSellCostBuyPrice+220, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+220
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+220, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+220
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+220
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '43', userid = '7', storedetaildate = '2022-08-20 21:00:29' WHERE storedetailid = '3924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '5', '1', '0', '2802', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '42.00', '43', '7', '2022-08-20 21:00:29','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 ('170.00', '00643', '2802', '1', '643', '1', '185.00', '185', '0', '', '2', '0', '643', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where returnsellbilldetailid = 6091;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (643, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 188.083333333, 170, 170, 170
                    , 170, 170, 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+188.083333333, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 188.083333333, 170, 170, 170
                    , 170, 170, 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+188.083333333, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '18', userid = '7', storedetaildate = '2022-08-20 21:00:29' WHERE storedetailid = '2270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('643', '5', '1', '0', '2802', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '17.00', '18', '7', '2022-08-20 21:00:29','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 ('165.00', '00989', '2802', '1', '989', '1', '185.00', '185', '0', '', '2', '0', '989', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 168.17, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 168.17
                where returnsellbilldetailid = 6092;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (989, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 188.083333333, 165, 180, 168.17
                    , 180, 168.17, 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+188.083333333, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+168.17, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+168.17
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 188.083333333, 165, 180, 168.17
                    , 180, 168.17, 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+188.083333333, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+168.17, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+168.17
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '7', storedetaildate = '2022-08-20 21:00:29' WHERE storedetailid = '3397';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('989', '5', '1', '0', '2802', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1.00', '2', '7', '2022-08-20 21:00:29','0','0');
UPDATE save SET  savecurrentvalue = '1470',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2060.00','590', '1', '5', 'اضافة فاتورة مردوات مبيعات', '2802', '1470', '2022-08-20 21:00:29', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 590, 555, 570, 558.17
                    , 570, 558.17, 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+590, returnSellCostBuyPrice = returnSellCostBuyPrice+555, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+570
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+558.17, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+570
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+558.17
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 590, 555, 570, 558.17
                    , 570, 558.17, 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+590, returnSellCostBuyPrice = returnSellCostBuyPrice+555, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+570
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+558.17, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+570
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+558.17
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -590, -555, -570
                    , -558.17, -570, -558.17, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-590, netSellCostBuyPrice = netSellCostBuyPrice+-555
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-570
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-558.17
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-570
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-558.17
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012f1982a6f and sellbillId = 2802 and returnsellbillId = 2802
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:30:29";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:00:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:00:29', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:32:12";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:02:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:02:12', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012f4e1de67
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:00:30', '063012f4e1de67', '1', '0.00', '0', '0', '1', '970', '970', '-970', '0', '5', '2022-08-20 21:02:12', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '5', '0', '', '','','','-1','0','0','0','','0','-970','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','2803', '0', '2022-08-20 21:02:12', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('255.00', '01112', '2803', '1', '1112', '1', '255.00', '255', '0', '', '0', '0', '1112', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
                where returnsellbilldetailid = 6093;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1112, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 255, 255, 255
                    , 255, 255, 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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+255, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+255
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+255, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+255
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+255
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 255, 255, 255
                    , 255, 255, 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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+255, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+255
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+255, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+255
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+255
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '7', storedetaildate = '2022-08-20 21:02:12' WHERE storedetailid = '4037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1112', '5', '1', '0', '2803', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '19.00', '20', '7', '2022-08-20 21:02:12','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 ('180.00', '01020', '2803', '1', '1020', '1', '180.00', '180', '0', '', '0', '0', '1020', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
                where returnsellbilldetailid = 6094;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1020, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 180, 180, 180
                    , 180, 180, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 180, 180, 180, 180
                    , 180, 180, 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+180, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '3', userid = '7', storedetaildate = '2022-08-20 21:02:12' WHERE storedetailid = '3568';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1020', '5', '1', '0', '2803', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '2.00', '3', '7', '2022-08-20 21:02:12','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 ('165.00', '00755', '2803', '1', '755', '1', '165', '165', '0', '', '0', '0', '755', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
                where returnsellbilldetailid = 6095;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (755, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 165, 165, 165, 165
                    , 165, 165, 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+165, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 165, 165, 165, 165
                    , 165, 165, 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+165, returnSellCostBuyPrice = returnSellCostBuyPrice+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '7', storedetaildate = '2022-08-20 21:02:12' WHERE storedetailid = '2395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('755', '5', '1', '0', '2803', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1.00', '2', '7', '2022-08-20 21:02:12','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 ('175.00', '01066', '2803', '1', '1066', '1', '175', '175', '0', '', '0', '0', '1066', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
                where returnsellbilldetailid = 6096;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1066, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 175, 175, 175, 175
                    , 175, 175, 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+175, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+175
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+175, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+175
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+175
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 175, 175, 175, 175
                    , 175, 175, 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+175, returnSellCostBuyPrice = returnSellCostBuyPrice+175, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+175
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+175, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+175
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+175
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '5', userid = '7', storedetaildate = '2022-08-20 21:02:12' WHERE storedetailid = '3785';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1066', '5', '1', '0', '2803', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4.00', '5', '7', '2022-08-20 21:02:12','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 ('195.00', '00854', '2803', '1', '854', '1', '195', '195', '0', '', '0', '0', '854', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
                where returnsellbilldetailid = 6097;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (854, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 195, 195, 195, 195
                    , 195, 195, 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+195, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 195, 195, 195, 195
                    , 195, 195, 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+195, returnSellCostBuyPrice = returnSellCostBuyPrice+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '7', storedetaildate = '2022-08-20 21:02:12' WHERE storedetailid = '3029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('854', '5', '1', '0', '2803', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '12.00', '13', '7', '2022-08-20 21:02:12','0','0');
UPDATE save SET  savecurrentvalue = '500',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1470.00','970', '1', '5', 'اضافة فاتورة مردوات مبيعات', '2803', '500', '2022-08-20 21:02:12', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 970, 970, 970
                    , 970, 970, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+970, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+970
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+970, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+970
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+970
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 970, 970, 970
                    , 970, 970, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+970, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+970
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+970, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+970
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+970
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -970, -970, -970
                    , -970, -970, -970, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-970, netSellCostBuyPrice = netSellCostBuyPrice+-970
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-970
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-970
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012f4e1de67 and sellbillId = 2803 and returnsellbillId = 2803
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:32:13";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:02:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:02:13', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:32:31";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:02:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:02:32', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:35:26";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:05:26", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:05:26', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063012fc82dfe8
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:02:32', '063012fc82dfe8', '1', '0.00', '0', '10', '1', '980', '970', '970', '0', '5', '2022-08-20 21:05:26', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','970','0','','0','0','970','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','اضافة فاتورة مبيعات','7815', '0', '2022-08-20 21:05:26', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7748;
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 ('265','01062', '7815', '1', '1062', '1', '275.00', '275', '0', '', '2', '2022-08-20 21:05:26', '1062', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','7748-1,');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
                where sellbilldetailid = 23443;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1062, '2022-08-20', 272.193877551, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+272.193877551, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , 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, '2022-08-20', 272.193877551, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+272.193877551, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+265
                            , 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 = '32', userid = '7', storedetaildate = '2022-08-20 21:05:26' WHERE storedetailid = '3765';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '5', '1', '1', '7815', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33.00', '32', '7', '2022-08-20 21:05:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7246;
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 ('160','00713', '7815', '1', '713', '1', '170.00', '170', '0', '', '2', '2022-08-20 21:05:26', '713', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','7246-1,');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 23444;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (713, '2022-08-20', 168.265306122, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+168.265306122, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, '2022-08-20', 168.265306122, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+168.265306122, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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 = '2022-08-20 21:05:26' WHERE storedetailid = '2551';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('713', '5', '1', '1', '7815', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '7', '2022-08-20 21:05:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7670;
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 ('170','01051', '7815', '1', '1051', '2', '180.00', '360', '0', '', '2', '2022-08-20 21:05:26', '1051', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','7670-1,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 23445;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1051, '2022-08-20', 356.326530612, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+356.326530612, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+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, '2022-08-20', 356.326530612, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+356.326530612, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '3', userid = '7', storedetaildate = '2022-08-20 21:05:26' WHERE storedetailid = '3730';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1051', '5', '2', '1', '7815', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '3', '7', '2022-08-20 21:05:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 668;
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 ('160','00434', '7815', '1', '434', '1', '175.00', '175', '0', '', '2', '2022-08-20 21:05:26', '434', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','668-1,');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 23446;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (434, '2022-08-20', 173.214285714, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+173.214285714, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , 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, '2022-08-20', 173.214285714, 160, 160
                    , 160, 160, 160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+173.214285714, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-1', userid = '7', storedetaildate = '2022-08-20 21:05:26' WHERE storedetailid = '885';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('434', '5', '1', '1', '7815', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0.00', '-1', '7', '2022-08-20 21:05:26','0','0');
UPDATE save SET  savecurrentvalue = '1470',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('500.00','970', '0', '5', 'اضافة فاتورة مبيعات', '7815', '1470', '2022-08-20 21:05:26', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 970, 925, 925
                    , 925, 925, 925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+925
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+925, sellCostMeanBuyPrice = sellCostMeanBuyPrice+925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+925, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+925
                            , 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, '2022-08-20', 970, 925, 925
                    , 925, 925, 925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+925
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+925, sellCostMeanBuyPrice = sellCostMeanBuyPrice+925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+925, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+925
                            , 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, 970, 925, 925
                    , 925, 925, 925, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+970, netSellCostBuyPrice = netSellCostBuyPrice+925
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+925
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+925
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+925
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+925
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063012fc82dfe8 and sellbillId = 7815 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:35:28";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:05:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:05:28', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:36:13";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:06:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:06:13', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063013078b9962
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:05:28', '063013078b9962', '1', '0.00', '0', '40', '1', '540', '500', '500', '0', '5', '2022-08-20 21:06:13', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','7816', '0', '2022-08-20 21:06:13', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 9044;
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 ('220','01074', '7816', '1', '1074', '2', '270.00', '540', '0', '', '1', '2022-08-20 21:06:13', '1074', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','9044-2,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23447;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 500, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+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, '2022-08-20', 500, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '41', userid = '7', storedetaildate = '2022-08-20 21:06:13' WHERE storedetailid = '3924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '5', '2', '1', '7816', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43.00', '41', '7', '2022-08-20 21:06:13','0','0');
UPDATE save SET  savecurrentvalue = '1970',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1470.00','500', '0', '5', 'اضافة فاتورة مبيعات', '7816', '1970', '2022-08-20 21:06:13', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 500, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 500, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 500, 440, 440
                    , 440, 440, 440, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063013078b9962 and sellbillId = 7816 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:36:14";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:06:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:06:14', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:01";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-08-20 21:07:01', '1', 'add', '156.210.34.51', '', 'DESKTOP');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment) VALUES ('7','9', '4000', '2022-08-20', '1', '0', '0','');
UPDATE save SET  savecurrentvalue = '100',  userid = '1' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4100.00','4000', '1', '7', 'تحويل امول الى الخزنة  [ الشيخ وليد ] ', '313', '100', '2022-08-20 21:07:01', '1',  'transfermoneyController.php','0','');
UPDATE save SET  savecurrentvalue = '3356660',  userid = '1' WHERE saveid = '9';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3352660.00','4000', '0', '9', 'تحويل امول من الخزنة  [ خزينة محل العميد ] ', '313', '3356660', '2022-08-20 21:07:01', '1',  'transfermoneyController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4000', '4000', '2022-08-20', '1', '0', '0', '2022-08-20 21:07:01','اضافة تحويل من خزينة محل العميد الى الشيخ وليد','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4463', '156', '4000', '','0');
UPDATE accountstree SET name = 'الشيخ وليد', customName = 'الشيخ وليد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-09', itemtype2 = '1', theValue = '3356660', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '156';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4463', '141', '4000', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-891125', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE transfermoney SET saveidfrom = '7', saveidto = '9', transfermoneyvalue = '4000.00', transfermoneydate = '2022-08-20', userid = '1', conditions = '0' , dailyentryid = '4463' , comment = '' WHERE transfermoneyid = '313';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:01";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-08-20 21:07:01', '1', 'sucess', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:03";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-08-20 21:07:04', '1', 'show', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:05";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:07:05', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:19";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:07:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:07:19', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630130a6b13c9
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:06:14', '0630130a6b13c9', '1', '0.00', '0', '0', '1', '520', '520', '520', '0', '5', '2022-08-20 21:07:19', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','520','0','','0','0','520','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','اضافة فاتورة مبيعات','7817', '0', '2022-08-20 21:07:19', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '520', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9044;
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 ('220','01074', '7817', '1', '1074', '1', '270.00', '270', '0', '', '1', '2022-08-20 21:07:19', '1074', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','9044-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23448;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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 = '40', userid = '7', storedetaildate = '2022-08-20 21:07:19' WHERE storedetailid = '3924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '5', '1', '1', '7817', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41.00', '40', '7', '2022-08-20 21:07:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7040;
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 ('210','01012', '7817', '1', '1012', '1', '250', '250', '0', '', '1', '2022-08-20 21:07:19', '1012', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','7040-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23449;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1012, '2022-08-20', 250, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 250, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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 = '2022-08-20 21:07:19' WHERE storedetailid = '3473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1012', '5', '1', '1', '7817', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22.00', '21', '7', '2022-08-20 21:07:19','0','0');
UPDATE save SET  savecurrentvalue = '2490',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1970.00','520', '0', '5', 'اضافة فاتورة مبيعات', '7817', '2490', '2022-08-20 21:07:19', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 520, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, 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, '2022-08-20', 520, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, 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, 520, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+520, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630130a6b13c9 and sellbillId = 7817 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:20";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:07:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:07:20', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:24";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:07:24', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:37:55";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:07:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:07:55', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:38:07";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:08:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:08:08', '7', 'addAndRetuen', '197.192.206.104', '', '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 0630130e87f9da
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(37,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2022-08-20 21:07:20', '0630130e87f9da', '37', '610.00', '675', '10', '1', '420', '410', '345', '65', '5', '2022-08-20 21:08:08', '', '7', '0', 'ام فريد', '5', '1', '3', '0', 'ام فريد', '2' ,'0','','','','','-1','0','0','0','0','0','410','0','','0','0','345','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '675', userid = '7' WHERE clientid = '37';
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 ('37','610.00','65','0','اضافة فاتورة مبيعات','7818', '675', '2022-08-20 21:08:08', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '410', '0', null, '0', null, null,'', '0','1','1','65','1');
UPDATE client SET  inUse = 0 where clientid = 37;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8694;
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 ('200','01118', '7818', '1', '1118', '1', '210', '210', '0', '', '0', '2022-08-20 21:08:08', '1118', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8694-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23450;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1118, '2022-08-20', 205, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 205, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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 = '2022-08-20 21:08:08' WHERE storedetailid = '4047';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1118', '5', '1', '1', '7818', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2022-08-20 21:08:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7452;
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 ('200','01047', '7818', '1', '1047', '1', '210.00', '210', '0', '', '0', '2022-08-20 21:08:08', '1047', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','7452-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23451;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1047, '2022-08-20', 205, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 205, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2022-08-20 21:08:08' WHERE storedetailid = '3656';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1047', '5', '1', '1', '7818', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '7', '2022-08-20 21:08:08','0','0');
UPDATE save SET  savecurrentvalue = '2835',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2490.00','345', '0', '5', 'اضافة فاتورة مبيعات', '7818', '2835', '2022-08-20 21:08:08', '7',  'sellbillController.php','37','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 410, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (37, '2022-08-20', 410, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 410, 400, 400
                    , 400, 400, 400, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+410, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+400
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+400
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630130e87f9da and sellbillId = 7818 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:38:08";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:08:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:08:09', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:38:14";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:08:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:08:14', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:38:21";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:08:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:08:21', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200', productSellAllPrice = '220.00', productSellUnitPrice = '260.00', productSellHalfPrice = '240.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '205',meanbuyprice_withDiscount = '205' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:08:30',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:08:30', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '205.00',meanbuyprice_withDiscount = '205' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:08:33',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:08:33', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '230', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '205.00',meanbuyprice_withDiscount = '205' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:08:37',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:08:37', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '240', productSellHalfPrice = '230.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '205.00',meanbuyprice_withDiscount = '205' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:08:46',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:08:46', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:39:12";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:09:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:09:12', '7', 'addAndRetuen', '197.192.206.104', '', '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 06301311ea7e0c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(37,@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 ('2022-08-20 21:08:14', '06301311ea7e0c', '37', '675.00', '0', '10', '1', '685', '675', '0', '-675', '5', '2022-08-20 21:09:13', '', '7', '0', 'ام فريد','5', '1', '5', '0', 'ام فريد', '3', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '37';
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 ('37','675.00','675','1','اضافة فاتورة مردوات مبيعات','2804', '0', '2022-08-20 21:09:13', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '675', '0', null, '0', null, null,'', '0','1','1','675','1');
UPDATE client SET  inUse = 0 where clientid = 37;
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 ('320.00', '00647', '2804', '1', '647', '1', '330.00', '330', '0', '', '0', '0', '647', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 304.38, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 304.38
                where returnsellbilldetailid = 6098;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (647, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 334.817518248, 320, 280, 304.38
                    , 280, 304.38, 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+334.817518248, returnSellCostBuyPrice = returnSellCostBuyPrice+320, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+304.38, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+304.38
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 334.817518248, 320, 280, 304.38
                    , 280, 304.38, 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+334.817518248, returnSellCostBuyPrice = returnSellCostBuyPrice+320, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+304.38, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+304.38
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '32', userid = '7', storedetaildate = '2022-08-20 21:09:13' WHERE storedetailid = '2268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('647', '5', '1', '0', '2804', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '31.00', '32', '7', '2022-08-20 21:09:13','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 ('170.00', '00643', '2804', '1', '643', '1', '175.00', '175', '0', '', '0', '0', '643', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where returnsellbilldetailid = 6099;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (643, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 177.554744526, 170, 170, 170
                    , 170, 170, 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+177.554744526, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 177.554744526, 170, 170, 170
                    , 170, 170, 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+177.554744526, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '7', storedetaildate = '2022-08-20 21:09:13' WHERE storedetailid = '2270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('643', '5', '1', '0', '2804', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '18.00', '19', '7', '2022-08-20 21:09:13','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 ('180.00', '01020', '2804', '1', '1020', '1', '180.00', '180', '0', '', '0', '0', '1020', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
                where returnsellbilldetailid = 6100;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1020, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 182.627737226, 180, 180, 180
                    , 180, 180, 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+182.627737226, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                            , 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, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 182.627737226, 180, 180, 180
                    , 180, 180, 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+182.627737226, returnSellCostBuyPrice = returnSellCostBuyPrice+180, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+180
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+180, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+180
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+180
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '7', storedetaildate = '2022-08-20 21:09:13' WHERE storedetailid = '3568';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1020', '5', '1', '0', '2804', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3.00', '4', '7', '2022-08-20 21:09:13','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 675, 670, 630, 654.38
                    , 630, 654.38, 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+675, returnSellCostBuyPrice = returnSellCostBuyPrice+670, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+654.38, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+654.38
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (37, '2022-08-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 675, 670, 630, 654.38
                    , 630, 654.38, 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+675, returnSellCostBuyPrice = returnSellCostBuyPrice+670, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+654.38, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+654.38
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -675, -670, -630
                    , -654.38, -630, -654.38, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-675, netSellCostBuyPrice = netSellCostBuyPrice+-670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-654.38
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-630
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-654.38
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06301311ea7e0c and sellbillId = 2804 and returnsellbillId = 2804
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:39:13";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:09:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:09:14', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '201', productSellUnitPrice = '201', productSellHalfPrice = '201', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '205.00',meanbuyprice_withDiscount = '205' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:54',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:54', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.03980891719746', productSellAllPrice = '201.00', productSellUnitPrice = '201.00', productSellHalfPrice = '201.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '202.52',meanbuyprice_withDiscount = '202.52' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:54',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:54', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.04', productSellAllPrice = '201.00', productSellUnitPrice = '241', productSellHalfPrice = '201.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '202.52',meanbuyprice_withDiscount = '202.52' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:54',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:54', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.04', productSellAllPrice = '201.00', productSellUnitPrice = '241.00', productSellHalfPrice = '231.04545454545453', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '202.52',meanbuyprice_withDiscount = '202.52' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:54',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:54', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.07962575814435', productSellAllPrice = '201.00', productSellUnitPrice = '241.00', productSellHalfPrice = '231.05', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '201.3',meanbuyprice_withDiscount = '201.3' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:58',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:58', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.08', productSellAllPrice = '201.00', productSellUnitPrice = '241.00', productSellHalfPrice = '232.09566115702478', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '201.30',meanbuyprice_withDiscount = '201.3' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:58',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:58', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.08', productSellAllPrice = '202.005', productSellUnitPrice = '202.005', productSellHalfPrice = '202.005', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '201.30',meanbuyprice_withDiscount = '201.3' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:58',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:58', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.08', productSellAllPrice = '202.01', productSellUnitPrice = '242.00416666666666', productSellHalfPrice = '202.01', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '201.30',meanbuyprice_withDiscount = '201.3' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:09:58',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:09:58', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:39:59";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:09:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:09:59', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200', productSellAllPrice = '202.01', productSellUnitPrice = '242.00', productSellHalfPrice = '202.01', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.65',meanbuyprice_withDiscount = '200.65' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:03',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:03', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.65',meanbuyprice_withDiscount = '200.65' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:09',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:09', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '220', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.65',meanbuyprice_withDiscount = '200.65' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:13',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:13', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '240', productSellHalfPrice = '220.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.65',meanbuyprice_withDiscount = '200.65' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:15',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:15', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.03980891719746', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '220.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.34',meanbuyprice_withDiscount = '200.34' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:16',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:16', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.04', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '221', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.34',meanbuyprice_withDiscount = '200.34' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:16',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:16', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.04', productSellAllPrice = '201', productSellUnitPrice = '201', productSellHalfPrice = '201', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.34',meanbuyprice_withDiscount = '200.34' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:16',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:16', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.04', productSellAllPrice = '201.00', productSellUnitPrice = '241', productSellHalfPrice = '201.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.34',meanbuyprice_withDiscount = '200.34' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:16',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:16', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200', productSellAllPrice = '201.00', productSellUnitPrice = '241.00', productSellHalfPrice = '201.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.17',meanbuyprice_withDiscount = '200.17' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:35',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:35', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.17',meanbuyprice_withDiscount = '200.17' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:38',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:38', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '220', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.17',meanbuyprice_withDiscount = '200.17' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:43',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:43', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '240', productSellHalfPrice = '220.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.17',meanbuyprice_withDiscount = '200.17' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:10:49',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:10:49', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:40:51";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:10:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:10:51', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:40:52";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:10:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:10:52', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0630131876e4f0
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:09:59', '0630131876e4f0', '1', '0.00', '0', '0', '1', '460', '460', '460', '0', '5', '2022-08-20 21:10:52', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'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','اضافة فاتورة مبيعات','7819', '0', '2022-08-20 21:10:52', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 2672;
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 ('170','00474', '7819', '1', '474', '1', '210', '210', '0', '', '1', '2022-08-20 21:10:52', '474', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','2672-1,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 23452;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (474, '2022-08-20', 210, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 210, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '24', userid = '7', storedetaildate = '2022-08-20 21:10:52' WHERE storedetailid = '1886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('474', '5', '1', '1', '7819', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25.00', '24', '7', '2022-08-20 21:10:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8694;
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 ('200','01118', '7819', '1', '1118', '1', '250', '250', '0', '', '1', '2022-08-20 21:10:52', '1118', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','8694-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 23453;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1118, '2022-08-20', 250, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , 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, '2022-08-20', 250, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '7', storedetaildate = '2022-08-20 21:10:52' WHERE storedetailid = '4047';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1118', '5', '1', '1', '7819', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '7', '2022-08-20 21:10:52','0','0');
UPDATE save SET  savecurrentvalue = '3295',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2835.00','460', '0', '5', 'اضافة فاتورة مبيعات', '7819', '3295', '2022-08-20 21:10:52', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 460, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-08-20', 460, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 460, 370, 370
                    , 370, 370, 370, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+370
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+370
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+370
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+370
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+370
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0630131876e4f0 and sellbillId = 7819 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:40:53";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:10:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:10:53', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:40:56";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:10:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:10:56', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:41:14";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:11:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:11:14', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:41:15";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:11:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:11:15', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:41:37";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:11:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:11:37', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:41:45";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:11:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:11:45', '7', 'showDetail', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:41:51";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:11:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:11:52', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:42:13";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:12:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:12:13', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:43:11";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:13:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:13:11', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:43:21";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:13:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:13:22', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:43:55";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:13:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:13:55', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '200.17',meanbuyprice_withDiscount = '200.17' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:14:52',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:14:52', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '300.09',meanbuyprice_withDiscount = '300.09' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:14:52',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:14:52', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '480', productSellHalfPrice = '400.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '300.09',meanbuyprice_withDiscount = '300.09' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:14:52',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:14:52', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '480.00', productSellHalfPrice = '440', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '300.09',meanbuyprice_withDiscount = '300.09' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:14:52',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:14:52', userid = 1;
UPDATE product SET productName = ' 200 دكرون', productDescription = '', productCatId = '1', productBuyPrice = '360', productSellAllPrice = '185.00', productSellUnitPrice = '215.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00136',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '160.00',lastbuyprice_withDiscount = '160',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '15.63' , buyhalf_precentage = '21.88' , buypart_precentage = '34.38',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '136';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (136, 1,'2022-08-20 21:17:11',1)
                ON DUPLICATE KEY UPDATE productid = 136, edited = 1, sysdate = '2022-08-20 21:17:11', userid = 1;
UPDATE product SET productName = ' 26 كريشه', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '165.00', productSellUnitPrice = '200.00', productSellHalfPrice = '165.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00139',type ='0', expireDate = '0' , dailyentryId = '139',isService = '0',isOptic = '0',lastbuyprice = '150.00',lastbuyprice_withDiscount = '150',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '139';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (139, 1,'2022-08-20 21:17:12',1)
                ON DUPLICATE KEY UPDATE productid = 139, edited = 1, sysdate = '2022-08-20 21:17:12', userid = 1;
UPDATE product SET productName = ' 501 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00172',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '172';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (172, 1,'2022-08-20 21:17:12',1)
                ON DUPLICATE KEY UPDATE productid = 172, edited = 1, sysdate = '2022-08-20 21:17:12', userid = 1;
UPDATE product SET productName = ' 513 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00175',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '175';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (175, 1,'2022-08-20 21:17:12',1)
                ON DUPLICATE KEY UPDATE productid = 175, edited = 1, sysdate = '2022-08-20 21:17:12', userid = 1;
UPDATE product SET productName = ' 33 CY', productDescription = '', productCatId = '1', productBuyPrice = '370', productSellAllPrice = '170.00', productSellUnitPrice = '200.00', productSellHalfPrice = '180.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00146',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '272.5',meanbuyprice_withDiscount = '272.5' , productbuypricereal = '170.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.88' , buypart_precentage = '17.65',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '146';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (146, 1,'2022-08-20 21:17:13',1)
                ON DUPLICATE KEY UPDATE productid = 146, edited = 1, sysdate = '2022-08-20 21:17:13', userid = 1;
UPDATE product SET productName = ' 506 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00174',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '174';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (174, 1,'2022-08-20 21:17:13',1)
                ON DUPLICATE KEY UPDATE productid = 174, edited = 1, sysdate = '2022-08-20 21:17:13', userid = 1;
UPDATE product SET productName = ' 520 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00181',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '181';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (181, 1,'2022-08-20 21:17:13',1)
                ON DUPLICATE KEY UPDATE productid = 181, edited = 1, sysdate = '2022-08-20 21:17:13', userid = 1;
UPDATE product SET productName = ' 7 كريشه', productDescription = '', productCatId = '1', productBuyPrice = '380', productSellAllPrice = '200.00', productSellUnitPrice = '250.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00200',type ='0', expireDate = '0' , dailyentryId = '200',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '280',meanbuyprice_withDiscount = '280' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '200';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (200, 1,'2022-08-20 21:17:13',1)
                ON DUPLICATE KEY UPDATE productid = 200, edited = 1, sysdate = '2022-08-20 21:17:13', userid = 1;
UPDATE product SET productName = ' 517 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00179',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '179';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (179, 1,'2022-08-20 21:17:13',1)
                ON DUPLICATE KEY UPDATE productid = 179, edited = 1, sysdate = '2022-08-20 21:17:13', userid = 1;
UPDATE product SET productName = '1012', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-12-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00602',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '602';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (602, 1,'2022-08-20 21:17:14',1)
                ON DUPLICATE KEY UPDATE productid = 602, edited = 1, sysdate = '2022-08-20 21:17:14', userid = 1;
UPDATE product SET productName = ' 708 كتان', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00201',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '298.75',meanbuyprice_withDiscount = '298.75' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '201';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (201, 1,'2022-08-20 21:17:14',1)
                ON DUPLICATE KEY UPDATE productid = 201, edited = 1, sysdate = '2022-08-20 21:17:14', userid = 1;
UPDATE product SET productName = '1013', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-12-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00601',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '601';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (601, 1,'2022-08-20 21:17:14',1)
                ON DUPLICATE KEY UPDATE productid = 601, edited = 1, sysdate = '2022-08-20 21:17:14', userid = 1;
UPDATE product SET productName = '1014', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-12-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00600',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '600';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (600, 1,'2022-08-20 21:17:14',1)
                ON DUPLICATE KEY UPDATE productid = 600, edited = 1, sysdate = '2022-08-20 21:17:14', userid = 1;
UPDATE product SET productName = ' 514 منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00176',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '291.25',meanbuyprice_withDiscount = '291.25' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '176';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (176, 1,'2022-08-20 21:17:15',1)
                ON DUPLICATE KEY UPDATE productid = 176, edited = 1, sysdate = '2022-08-20 21:17:15', userid = 1;
UPDATE product SET productName = '1009', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-12-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00603',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '603';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (603, 1,'2022-08-20 21:17:15',1)
                ON DUPLICATE KEY UPDATE productid = 603, edited = 1, sysdate = '2022-08-20 21:17:15', userid = 1;
UPDATE product SET productName = '104كريشه', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00219',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '297.5',meanbuyprice_withDiscount = '297.5' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '219';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (219, 1,'2022-08-20 21:17:15',1)
                ON DUPLICATE KEY UPDATE productid = 219, edited = 1, sysdate = '2022-08-20 21:17:15', userid = 1;
UPDATE product SET productName = '106', productDescription = '', productCatId = '1', productBuyPrice = '395', productSellAllPrice = '200.00', productSellUnitPrice = '230.00', productSellHalfPrice = '210.00', productDate = '2021-12-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00595',type ='0', expireDate = '0' , dailyentryId = '741',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '195.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.56' , buyhalf_precentage = '7.69' , buypart_precentage = '17.95',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '595';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (595, 1,'2022-08-20 21:17:15',1)
                ON DUPLICATE KEY UPDATE productid = 595, edited = 1, sysdate = '2022-08-20 21:17:15', userid = 1;
UPDATE product SET productName = '11', productDescription = '', productCatId = '1', productBuyPrice = '370', productSellAllPrice = '180.00', productSellUnitPrice = '210.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00011',type ='0', expireDate = '0' , dailyentryId = '11',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '11';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (11, 1,'2022-08-20 21:17:16',1)
                ON DUPLICATE KEY UPDATE productid = 11, edited = 1, sysdate = '2022-08-20 21:17:16', userid = 1;
UPDATE product SET productName = '110', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '200.00', productSellUnitPrice = '230.00', productSellHalfPrice = '210.00', productDate = '2021-12-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00594',type ='0', expireDate = '0' , dailyentryId = '740',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '5.26' , buyhalf_precentage = '10.53' , buypart_precentage = '21.05',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '594';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (594, 1,'2022-08-20 21:17:16',1)
                ON DUPLICATE KEY UPDATE productid = 594, edited = 1, sysdate = '2022-08-20 21:17:16', userid = 1;
UPDATE product SET productName = '104', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00031',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '31';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (31, 1,'2022-08-20 21:17:16',1)
                ON DUPLICATE KEY UPDATE productid = 31, edited = 1, sysdate = '2022-08-20 21:17:16', userid = 1;
UPDATE product SET productName = '2000', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00576',type ='0', expireDate = '0' , dailyentryId = '679',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '576';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (576, 1,'2022-08-20 21:17:16',1)
                ON DUPLICATE KEY UPDATE productid = 576, edited = 1, sysdate = '2022-08-20 21:17:16', userid = 1;
UPDATE product SET productName = '20 سي واي', productDescription = '', productCatId = '1', productBuyPrice = '360', productSellAllPrice = '160.00', productSellUnitPrice = '200.00', productSellHalfPrice = '170.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00237',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '263.75',meanbuyprice_withDiscount = '263.75' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '25.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '237';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (237, 1,'2022-08-20 21:17:17',1)
                ON DUPLICATE KEY UPDATE productid = 237, edited = 1, sysdate = '2022-08-20 21:17:17', userid = 1;
UPDATE product SET productName = '114', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '215.00', productSellUnitPrice = '245.00', productSellHalfPrice = '215.00', productDate = '2021-12-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00592',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '7.50' , buyhalf_precentage = '0.00' , buypart_precentage = '22.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '592';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (592, 1,'2022-08-20 21:17:17',1)
                ON DUPLICATE KEY UPDATE productid = 592, edited = 1, sysdate = '2022-08-20 21:17:17', userid = 1;
UPDATE product SET productName = '104منتش', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00220',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '205.00',lastbuyprice_withDiscount = '205',meanbuyprice = '301.25',meanbuyprice_withDiscount = '301.25' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '220';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (220, 1,'2022-08-20 21:17:17',1)
                ON DUPLICATE KEY UPDATE productid = 220, edited = 1, sysdate = '2022-08-20 21:17:17', userid = 1;
UPDATE product SET productName = '2005', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00579',type ='0', expireDate = '0' , dailyentryId = '682',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '579';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (579, 1,'2022-08-20 21:17:17',1)
                ON DUPLICATE KEY UPDATE productid = 579, edited = 1, sysdate = '2022-08-20 21:17:17', userid = 1;
UPDATE product SET productName = '2007', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00582',type ='0', expireDate = '0' , dailyentryId = '685',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '582';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (582, 1,'2022-08-20 21:17:18',1)
                ON DUPLICATE KEY UPDATE productid = 582, edited = 1, sysdate = '2022-08-20 21:17:18', userid = 1;
UPDATE product SET productName = '2004', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00575',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '575';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (575, 1,'2022-08-20 21:17:18',1)
                ON DUPLICATE KEY UPDATE productid = 575, edited = 1, sysdate = '2022-08-20 21:17:18', userid = 1;
UPDATE product SET productName = '2003', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00581',type ='0', expireDate = '0' , dailyentryId = '684',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '581';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (581, 1,'2022-08-20 21:17:18',1)
                ON DUPLICATE KEY UPDATE productid = 581, edited = 1, sysdate = '2022-08-20 21:17:18', userid = 1;
UPDATE product SET productName = '115', productDescription = '', productCatId = '1', productBuyPrice = '395', productSellAllPrice = '200.00', productSellUnitPrice = '245.00', productSellHalfPrice = '215.00', productDate = '2021-12-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00591',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195.00',lastbuyprice_withDiscount = '195',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '195.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.56' , buyhalf_precentage = '10.26' , buypart_precentage = '25.64',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '591';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (591, 1,'2022-08-20 21:17:18',1)
                ON DUPLICATE KEY UPDATE productid = 591, edited = 1, sysdate = '2022-08-20 21:17:18', userid = 1;
UPDATE product SET productName = '244داكرون', productDescription = '', productCatId = '1', productBuyPrice = '370', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00239',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '11.76' , buyhalf_precentage = '17.65' , buypart_precentage = '29.41',logo = '249477677a968e1d30090f965d443340.jpg',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '239';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (239, 1,'2022-08-20 21:17:18',1)
                ON DUPLICATE KEY UPDATE productid = 239, edited = 1, sysdate = '2022-08-20 21:17:18', userid = 1;
UPDATE product SET productName = '436', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-30', conditions = '0', userId = '1', limitamount = '0', parcode = '00588',type ='0', expireDate = '0' , dailyentryId = '700',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '588';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (588, 1,'2022-08-20 21:17:19',1)
                ON DUPLICATE KEY UPDATE productid = 588, edited = 1, sysdate = '2022-08-20 21:17:19', userid = 1;
UPDATE product SET productName = '2006', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00578',type ='0', expireDate = '0' , dailyentryId = '681',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '578';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (578, 1,'2022-08-20 21:17:19',1)
                ON DUPLICATE KEY UPDATE productid = 578, edited = 1, sysdate = '2022-08-20 21:17:19', userid = 1;
UPDATE product SET productName = '2008', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00580',type ='0', expireDate = '0' , dailyentryId = '683',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '580';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (580, 1,'2022-08-20 21:17:19',1)
                ON DUPLICATE KEY UPDATE productid = 580, edited = 1, sysdate = '2022-08-20 21:17:19', userid = 1;
UPDATE product SET productName = '256داكرون', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '200.00', productSellUnitPrice = '220.00', productSellHalfPrice = '210.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00241',type ='0', expireDate = '0' , dailyentryId = '241',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '290',meanbuyprice_withDiscount = '290' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '241';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (241, 1,'2022-08-20 21:17:19',1)
                ON DUPLICATE KEY UPDATE productid = 241, edited = 1, sysdate = '2022-08-20 21:17:19', userid = 1;
UPDATE product SET productName = '2014', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2021-11-25', conditions = '0', userId = '1', limitamount = '0', parcode = '00577',type ='0', expireDate = '0' , dailyentryId = '680',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '577';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (577, 1,'2022-08-20 21:17:20',1)
                ON DUPLICATE KEY UPDATE productid = 577, edited = 1, sysdate = '2022-08-20 21:17:20', userid = 1;
UPDATE product SET productName = '476', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '190.00', productSellUnitPrice = '220.00', productSellHalfPrice = '200.00', productDate = '2022-01-16', conditions = '0', userId = '1', limitamount = '0', parcode = '00637',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '285',meanbuyprice_withDiscount = '285' , productbuypricereal = '185.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '2.70' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '637';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (637, 1,'2022-08-20 21:17:20',1)
                ON DUPLICATE KEY UPDATE productid = 637, edited = 1, sysdate = '2022-08-20 21:17:20', userid = 1;
UPDATE product SET productName = '475دكرون', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-23', conditions = '0', userId = '1', limitamount = '0', parcode = '00572',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '302.5',meanbuyprice_withDiscount = '302.5' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '572';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (572, 1,'2022-08-20 21:17:20',1)
                ON DUPLICATE KEY UPDATE productid = 572, edited = 1, sysdate = '2022-08-20 21:17:20', userid = 1;
UPDATE product SET productName = '513', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00082',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '292.5',meanbuyprice_withDiscount = '292.5' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '82';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (82, 1,'2022-08-20 21:17:20',1)
                ON DUPLICATE KEY UPDATE productid = 82, edited = 1, sysdate = '2022-08-20 21:17:20', userid = 1;
UPDATE product SET productName = '503', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '210.00', productSellUnitPrice = '240.00', productSellHalfPrice = '225.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00079',type ='0', expireDate = '0' , dailyentryId = '79',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '79';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (79, 1,'2022-08-20 21:17:20',1)
                ON DUPLICATE KEY UPDATE productid = 79, edited = 1, sysdate = '2022-08-20 21:17:20', userid = 1;
UPDATE product SET productName = '506', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00080',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '292.5',meanbuyprice_withDiscount = '292.5' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '80';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (80, 1,'2022-08-20 21:17:21',1)
                ON DUPLICATE KEY UPDATE productid = 80, edited = 1, sysdate = '2022-08-20 21:17:21', userid = 1;
UPDATE product SET productName = '5024', productDescription = '', productCatId = '1', productBuyPrice = '600', productSellAllPrice = '400.00', productSellUnitPrice = '480.00', productSellHalfPrice = '440.00', productDate = '2022-08-18', conditions = '0', userId = '1', limitamount = '0', parcode = '01126',type ='0', expireDate = '0' , dailyentryId = '4436',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '450.05',meanbuyprice_withDiscount = '450.05' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '4.76' , buyhalf_precentage = '14.29' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1126';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1126, 1,'2022-08-20 21:17:21',1)
                ON DUPLICATE KEY UPDATE productid = 1126, edited = 1, sysdate = '2022-08-20 21:17:21', userid = 1;
UPDATE product SET productName = '501', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00077',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '292.5',meanbuyprice_withDiscount = '292.5' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '77';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (77, 1,'2022-08-20 21:17:21',1)
                ON DUPLICATE KEY UPDATE productid = 77, edited = 1, sysdate = '2022-08-20 21:17:21', userid = 1;
UPDATE product SET productName = '514', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00083',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '292.5',meanbuyprice_withDiscount = '292.5' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '83';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (83, 1,'2022-08-20 21:17:21',1)
                ON DUPLICATE KEY UPDATE productid = 83, edited = 1, sysdate = '2022-08-20 21:17:21', userid = 1;
UPDATE product SET productName = '514منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00274',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '205.00',lastbuyprice_withDiscount = '205',meanbuyprice = '293.75',meanbuyprice_withDiscount = '293.75' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '274';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (274, 1,'2022-08-20 21:17:22',1)
                ON DUPLICATE KEY UPDATE productid = 274, edited = 1, sysdate = '2022-08-20 21:17:22', userid = 1;
UPDATE product SET productName = '519', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '210.00', productSellUnitPrice = '240.00', productSellHalfPrice = '225.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00088',type ='0', expireDate = '0' , dailyentryId = '88',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '88';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (88, 1,'2022-08-20 21:17:22',1)
                ON DUPLICATE KEY UPDATE productid = 88, edited = 1, sysdate = '2022-08-20 21:17:22', userid = 1;
UPDATE product SET productName = '517منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00276',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '205.00',lastbuyprice_withDiscount = '205',meanbuyprice = '293.75',meanbuyprice_withDiscount = '293.75' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '276';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (276, 1,'2022-08-20 21:17:22',1)
                ON DUPLICATE KEY UPDATE productid = 276, edited = 1, sysdate = '2022-08-20 21:17:22', userid = 1;
UPDATE product SET productName = '527', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-23', conditions = '0', userId = '1', limitamount = '0', parcode = '00570',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '570';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (570, 1,'2022-08-20 21:17:22',1)
                ON DUPLICATE KEY UPDATE productid = 570, edited = 1, sysdate = '2022-08-20 21:17:22', userid = 1;
UPDATE product SET productName = '513منتش', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00273',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '205.00',lastbuyprice_withDiscount = '205',meanbuyprice = '293.75',meanbuyprice_withDiscount = '293.75' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '273';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (273, 1,'2022-08-20 21:17:23',1)
                ON DUPLICATE KEY UPDATE productid = 273, edited = 1, sysdate = '2022-08-20 21:17:23', userid = 1;
UPDATE product SET productName = '528', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-01-09', conditions = '0', userId = '1', limitamount = '0', parcode = '00634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '302.5',meanbuyprice_withDiscount = '302.5' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (634, 1,'2022-08-20 21:17:23',1)
                ON DUPLICATE KEY UPDATE productid = 634, edited = 1, sysdate = '2022-08-20 21:17:23', userid = 1;
UPDATE product SET productName = '517', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00086',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '292.5',meanbuyprice_withDiscount = '292.5' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '86';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (86, 1,'2022-08-20 21:17:23',1)
                ON DUPLICATE KEY UPDATE productid = 86, edited = 1, sysdate = '2022-08-20 21:17:23', userid = 1;
UPDATE product SET productName = '6005', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00940',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '940';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (940, 1,'2022-08-20 21:17:23',1)
                ON DUPLICATE KEY UPDATE productid = 940, edited = 1, sysdate = '2022-08-20 21:17:23', userid = 1;
UPDATE product SET productName = '6004 سفره', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '220.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00937',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '18.18',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '937';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (937, 1,'2022-08-20 21:17:24',1)
                ON DUPLICATE KEY UPDATE productid = 937, edited = 1, sysdate = '2022-08-20 21:17:24', userid = 1;
UPDATE product SET productName = '6005 كرافته', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00944',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '944';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (944, 1,'2022-08-20 21:17:24',1)
                ON DUPLICATE KEY UPDATE productid = 944, edited = 1, sysdate = '2022-08-20 21:17:24', userid = 1;
UPDATE product SET productName = '6008', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00943',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '943';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (943, 1,'2022-08-20 21:17:24',1)
                ON DUPLICATE KEY UPDATE productid = 943, edited = 1, sysdate = '2022-08-20 21:17:24', userid = 1;
UPDATE product SET productName = '6006', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00945',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '945';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (945, 1,'2022-08-20 21:17:24',1)
                ON DUPLICATE KEY UPDATE productid = 945, edited = 1, sysdate = '2022-08-20 21:17:24', userid = 1;
UPDATE product SET productName = '6009', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00941',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '941';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (941, 1,'2022-08-20 21:17:24',1)
                ON DUPLICATE KEY UPDATE productid = 941, edited = 1, sysdate = '2022-08-20 21:17:24', userid = 1;
UPDATE product SET productName = '525', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '190.00', productSellUnitPrice = '230.00', productSellHalfPrice = '200.00', productDate = '2021-11-23', conditions = '0', userId = '1', limitamount = '0', parcode = '00571',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '190.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.26' , buypart_precentage = '21.05',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '571';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (571, 1,'2022-08-20 21:17:25',1)
                ON DUPLICATE KEY UPDATE productid = 571, edited = 1, sysdate = '2022-08-20 21:17:25', userid = 1;
UPDATE product SET productName = '6011', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00947',type ='0', expireDate = '0' , dailyentryId = '2434',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '947';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (947, 1,'2022-08-20 21:17:25',1)
                ON DUPLICATE KEY UPDATE productid = 947, edited = 1, sysdate = '2022-08-20 21:17:25', userid = 1;
UPDATE product SET productName = '6012', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00948',type ='0', expireDate = '0' , dailyentryId = '2435',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '948';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (948, 1,'2022-08-20 21:17:25',1)
                ON DUPLICATE KEY UPDATE productid = 948, edited = 1, sysdate = '2022-08-20 21:17:25', userid = 1;
UPDATE product SET productName = '6013', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00949',type ='0', expireDate = '0' , dailyentryId = '2436',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '949';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (949, 1,'2022-08-20 21:17:25',1)
                ON DUPLICATE KEY UPDATE productid = 949, edited = 1, sysdate = '2022-08-20 21:17:25', userid = 1;
UPDATE product SET productName = '526', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2021-11-23', conditions = '0', userId = '1', limitamount = '0', parcode = '00569',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '302.5',meanbuyprice_withDiscount = '302.5' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '569';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (569, 1,'2022-08-20 21:17:26',1)
                ON DUPLICATE KEY UPDATE productid = 569, edited = 1, sysdate = '2022-08-20 21:17:26', userid = 1;
UPDATE product SET productName = '6015', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00957',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '957';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (957, 1,'2022-08-20 21:17:26',1)
                ON DUPLICATE KEY UPDATE productid = 957, edited = 1, sysdate = '2022-08-20 21:17:26', userid = 1;
UPDATE product SET productName = '6010', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00946',type ='0', expireDate = '0' , dailyentryId = '2433',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '946';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (946, 1,'2022-08-20 21:17:26',1)
                ON DUPLICATE KEY UPDATE productid = 946, edited = 1, sysdate = '2022-08-20 21:17:26', userid = 1;
UPDATE product SET productName = '6016', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00959',type ='0', expireDate = '0' , dailyentryId = '2464',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '959';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (959, 1,'2022-08-20 21:17:26',1)
                ON DUPLICATE KEY UPDATE productid = 959, edited = 1, sysdate = '2022-08-20 21:17:26', userid = 1;
UPDATE product SET productName = '6007', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00942',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '942';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (942, 1,'2022-08-20 21:17:27',1)
                ON DUPLICATE KEY UPDATE productid = 942, edited = 1, sysdate = '2022-08-20 21:17:27', userid = 1;
UPDATE product SET productName = '6018', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00963',type ='0', expireDate = '0' , dailyentryId = '2474',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '963';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (963, 1,'2022-08-20 21:17:27',1)
                ON DUPLICATE KEY UPDATE productid = 963, edited = 1, sysdate = '2022-08-20 21:17:27', userid = 1;
UPDATE product SET productName = '624', productDescription = '', productCatId = '1', productBuyPrice = '375', productSellAllPrice = '185.00', productSellUnitPrice = '215.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00113',type ='0', expireDate = '0' , dailyentryId = '113',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '113';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (113, 1,'2022-08-20 21:17:27',1)
                ON DUPLICATE KEY UPDATE productid = 113, edited = 1, sysdate = '2022-08-20 21:17:27', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:47:27";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:17:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:17:27', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE product SET productName = '626', productDescription = '', productCatId = '1', productBuyPrice = '360', productSellAllPrice = '170.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00115',type ='0', expireDate = '0' , dailyentryId = '115',isService = '0',isOptic = '0',lastbuyprice = '160.00',lastbuyprice_withDiscount = '160',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '115';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (115, 1,'2022-08-20 21:17:28',1)
                ON DUPLICATE KEY UPDATE productid = 115, edited = 1, sysdate = '2022-08-20 21:17:28', userid = 1;
UPDATE product SET productName = '9025', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '210.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2022-07-21', conditions = '0', userId = '1', limitamount = '0', parcode = '01118',type ='0', expireDate = '0' , dailyentryId = '4131',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1118';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1118, 1,'2022-08-20 21:17:28',1)
                ON DUPLICATE KEY UPDATE productid = 1118, edited = 1, sysdate = '2022-08-20 21:17:28', userid = 1;
UPDATE product SET productName = '6014', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00956',type ='0', expireDate = '0' , dailyentryId = '2458',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '956';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (956, 1,'2022-08-20 21:17:28',1)
                ON DUPLICATE KEY UPDATE productid = 956, edited = 1, sysdate = '2022-08-20 21:17:28', userid = 1;
UPDATE product SET productName = '625', productDescription = '', productCatId = '1', productBuyPrice = '375', productSellAllPrice = '185.00', productSellUnitPrice = '215.00', productSellHalfPrice = '200.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00114',type ='0', expireDate = '0' , dailyentryId = '114',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '114';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (114, 1,'2022-08-20 21:17:29',1)
                ON DUPLICATE KEY UPDATE productid = 114, edited = 1, sysdate = '2022-08-20 21:17:29', userid = 1;
UPDATE product SET productName = '621امهات', productDescription = '', productCatId = '1', productBuyPrice = '365', productSellAllPrice = '170.00', productSellUnitPrice = '200.00', productSellHalfPrice = '180.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00290',type ='0', expireDate = '0' , dailyentryId = '290',isService = '0',isOptic = '0',lastbuyprice = '165.00',lastbuyprice_withDiscount = '165',meanbuyprice = '265',meanbuyprice_withDiscount = '265' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '290';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (290, 1,'2022-08-20 21:17:29',1)
                ON DUPLICATE KEY UPDATE productid = 290, edited = 1, sysdate = '2022-08-20 21:17:29', userid = 1;
UPDATE product SET productName = '6017', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00964',type ='0', expireDate = '0' , dailyentryId = '2475',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '964';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (964, 1,'2022-08-20 21:17:29',1)
                ON DUPLICATE KEY UPDATE productid = 964, edited = 1, sysdate = '2022-08-20 21:17:29', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:51:09";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:21:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:21:10', '1', 'showNew', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:51:59";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:22:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:22:00', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:52:03";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:22:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:22:03', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:02";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:25:02', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:39";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:25:40', '7', 'add', '197.192.206.104', '', 'DESKTOP');
BEGIN;
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('1', '-975601.00', '3000', '1', 'ايصال دفع لمورد', '171', '-978601', '2022-08-20 21:25:02', '7', 'supplierPayedDeptController.php', 'جمعيه اودي', '0','5', '-1','1','1','1','1');
UPDATE supplier SET  suppliercurrentDebt = '-978601', userid = '7', supplierdate = '2022-08-20 21:25:40'   WHERE supplierid = '1';
UPDATE save SET  savecurrentvalue = '295',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3295.00','3000', '1', '5', 'ايصال دفع لمورد', '546', '295', '2022-08-20 21:25:40', '7',  'supplierPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '3000', '3000', '2022-08-20', '7', '0', '0', '2022-08-20 21:25:40','ايصال دفع لمورد ( مباشر ) ','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4464', '168', '3000', '','0');
UPDATE accountstree SET name = 'مباشر', customName = 'مباشر', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '7', mydate = '2021-12-11', itemtype2 = '1', theValue = '-978601', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '168';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4464', '139', '3000', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1011339', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE supplierdebtchange SET supplierid = '1', supplierdebtchangebefore = '-975601.00', supplierdebtchangeamount = '3000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '171', supplierdebtchangeafter = '-978601.00', supplierdebtchangedate = '2022-08-20 21:25:02', userid = '7', tablename = 'supplierPayedDeptController.php', comment = 'جمعيه اودي', dailyentryid = '4464',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE supplierdebtchangeid = '546';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:40";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:25:40', '7', 'sucess', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:44";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:25:44', '7', 'show', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:44";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2022-08-20 21:25:45', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:55:51";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:25:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:25:51', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:56:15";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:26:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2022-08-20 21:26:15', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:56:22";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:26:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:26:22', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:58:54";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:28:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:28:54', '1', 'add', '156.210.34.51', '', 'DESKTOP');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('5024 مراسي','','1','200','200', '240','220', '2022-08-20', '0', '1', '0', '', '0', '0', '0', '0', '0', '200','200','200','200','200','0','0','10','20','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '5024 مراسي', productDescription = '', productCatId = '1', productBuyPrice = '200', productSellAllPrice = '200', productSellUnitPrice = '240', productSellHalfPrice = '220', productDate = '2022-08-20', conditions = '0', userId = '1', limitamount = '0', parcode = '01128',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '10' , buypart_precentage = '20',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1128';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1128', '1', '2022-08-20', '1', '0','0112801','200','220','240','200');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1128', '1', '276', '1', '2022-08-20');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '1', '276', '0', '1128', 'إضافة منتج', 'productController.php', '0', '276', '1', '2022-08-20','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1128, 1,'2022-08-20 21:28:54',1)
                ON DUPLICATE KEY UPDATE productid = 1128, edited = 1, sysdate = '2022-08-20 21:28:54', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '55200', '55200', '2022-08-20', '1', '0', '0', '2022-08-20 21:28:54','إضافة منتج 5024 مراسي الكمية 276','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4465', '19', '55200', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10387680.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4465', '7', '55200', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11156126.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '5024 مراسي', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '220.00', productDate = '2022-08-20', conditions = '0', userId = '1', limitamount = '0', parcode = '01128',type ='0', expireDate = '0' , dailyentryId = '4465',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '10' , buypart_precentage = '20',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1128';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:58:56";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:28:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-08-20 21:28:56', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:58:57";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:28:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:28:57', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:59:50";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:29:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:29:50', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06301353fc95fe
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 21:25:51', '06301353fc95fe', '1', '0.00', '0', '10', '1', '510', '500', '500', '0', '5', '2022-08-20 21:29:50', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','7820', '0', '2022-08-20 21:29:50', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8694;
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 ('200','01118', '7820', '1', '1118', '1', '250', '250', '0', '', '1', '2022-08-20 21:29:50', '1118', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','8694-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 23454;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1118, '2022-08-20', 245.098039216, 400, 200
                    , 300, 200, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245.098039216, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-08-20', 245.098039216, 400, 200
                    , 300, 200, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245.098039216, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '7', storedetaildate = '2022-08-20 21:29:50' WHERE storedetailid = '4047';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1118', '5', '1', '1', '7820', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '8', '7', '2022-08-20 21:29:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7750;
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 ('210','01063', '7820', '1', '1063', '1', '260', '260', '0', '', '1', '2022-08-20 21:29:50', '1063', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','7750-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 23455;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1063, '2022-08-20', 254.901960784, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+254.901960784, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , 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, '2022-08-20', 254.901960784, 210, 210
                    , 210, 210, 210, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+254.901960784, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '5', userid = '7', storedetaildate = '2022-08-20 21:29:50' WHERE storedetailid = '3766';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1063', '5', '1', '1', '7820', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '7', '2022-08-20 21:29:50','0','0');
UPDATE save SET  savecurrentvalue = '795',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('295.00','500', '0', '5', 'اضافة فاتورة مبيعات', '7820', '795', '2022-08-20 21:29:50', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 500, 610, 410
                    , 510, 410, 510, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+610
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , 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, '2022-08-20', 500, 610, 410
                    , 510, 410, 510, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+610
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+510
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 500, 610, 410
                    , 510, 410, 510, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+610
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+510
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+510
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06301353fc95fe and sellbillId = 7820 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:59:52";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:29:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:29:52', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 17:59:58";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:29:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:29:58', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:00:49";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 21:30:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:30:49', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:03:50";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:33:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:33:50', '1', 'add', '156.210.34.51', '', '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(1061,1,3,1122,44,'2022-08-20',1,0, '' ,0,0,0,0,0,'2022-08-20 21:33:50',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '88', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4093';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1122, 0, 0
                    , 210.00, -44, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-44, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "44*2022-08-20*210.00," WHERE transferproductid = 4534;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '1', '44', '1', '4534', 'تحويل منتجات من المخزن', 'storemovementController.php', '132.00', '88', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1122', '3', '44', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 1122, 0, 0
                    , 210.00, 44, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+44, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '3', '44', '0', '4534', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '44', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '3', '492', '25', '2022-08-20', '1', '0','1061',null,null,'2022-08-20 21:33:50',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '144', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '492';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 492, 0, 0
                    , 180.00, -25, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 180.00,
                        buyQuantity =buyQuantity+-25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "25*2022-08-20*180.00," WHERE transferproductid = 4535;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('492', '1', '25', '1', '4535', 'تحويل منتجات من المخزن', 'storemovementController.php', '169.00', '144', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('492', '3', '25', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 492, 0, 0
                    , 180.00, 25, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('492', '3', '25', '0', '4535', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '25', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '3', '1124', '41', '2022-08-20', '1', '0','1061',null,null,'2022-08-20 21:33:50',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '127', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4095';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1124, 0, 0
                    , 210.00, -41, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "41*2022-08-20*210.00," WHERE transferproductid = 4536;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '1', '41', '1', '4536', 'تحويل منتجات من المخزن', 'storemovementController.php', '168.00', '127', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1124', '3', '41', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 1124, 0, 0
                    , 210.00, 41, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '3', '41', '0', '4536', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '41', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '3', '1123', '43', '2022-08-20', '1', '0','1061',null,null,'2022-08-20 21:33:50',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '285', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4094';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1123, 0, 0
                    , 200.00, -43, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-43, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "43*2022-08-20*200.00," WHERE transferproductid = 4537;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '1', '43', '1', '4537', 'تحويل منتجات من المخزن', 'storemovementController.php', '328.00', '285', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1123', '3', '43', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 1123, 0, 0
                    , 200.00, 43, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+43, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '3', '43', '0', '4537', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '43', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '3', '1125', '32', '2022-08-20', '1', '0','1061',null,null,'2022-08-20 21:33:50',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '124', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4096';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1125, 0, 0
                    , 210.00, -32, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2022-08-20*210.00," WHERE transferproductid = 4538;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '1', '32', '1', '4538', 'تحويل منتجات من المخزن', 'storemovementController.php', '156.00', '124', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1125', '3', '32', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 1125, 0, 0
                    , 210.00, 32, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '3', '32', '0', '4538', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '32', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '3', '1128', '28', '2022-08-20', '1', '0','1061',null,null,'2022-08-20 21:33:50',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '248', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4111';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1128, 0, 0
                    , 200.00, -28, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "28*2022-08-20*200.00," WHERE transferproductid = 4539;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '1', '28', '1', '4539', 'تحويل منتجات من المخزن', 'storemovementController.php', '276.00', '248', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1128', '3', '28', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 3, 1128, 0, 0
                    , 200.00, 28, 0, 0, 1, '2022-08-20 21:33:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:33:50' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '3', '28', '0', '4539', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '28', '1', '2022-08-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:03:50";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:33:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:33:50', '1', 'editshow', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:04:51";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:34:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:34:51', '1', '', '156.210.34.51', '', '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 < "2022-08-20 18:06:34";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:36:34", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-08-20 21:36:34', '5', '', '197.55.113.160', '', '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 < "2022-08-20 18:06: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 < "2022-08-20 18:06:45";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:36:45", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:36:45', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:23";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:37:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:37:23', '1', 'add', '156.210.34.51', '', '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(1062,1,5,1122,44,'2022-08-20',1,0, '' ,0,0,0,0,0,'2022-08-20 21:37:23',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '44', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4093';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1122, 0, 0
                    , 210.00, -44, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-44, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "44*2022-08-20*210.00," WHERE transferproductid = 4540;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '1', '44', '1', '4540', 'تحويل منتجات من المخزن', 'storemovementController.php', '88.00', '44', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1122', '5', '44', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 1122, 0, 0
                    , 210.00, 44, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+44, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '5', '44', '0', '4540', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '44', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '492', '32', '2022-08-20', '1', '0','1062',null,null,'2022-08-20 21:37:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '112', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '492';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 492, 0, 0
                    , 180.00, -32, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 180.00,
                        buyQuantity =buyQuantity+-32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2022-08-20*180.00," WHERE transferproductid = 4541;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('492', '1', '32', '1', '4541', 'تحويل منتجات من المخزن', 'storemovementController.php', '144.00', '112', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '876';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 492, 0, 0
                    , 180.00, 32, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('492', '5', '32', '0', '4541', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '32', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1124', '41', '2022-08-20', '1', '0','1062',null,null,'2022-08-20 21:37:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '86', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4095';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1124, 0, 0
                    , 210.00, -41, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "41*2022-08-20*210.00," WHERE transferproductid = 4542;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '1', '41', '1', '4542', 'تحويل منتجات من المخزن', 'storemovementController.php', '127.00', '86', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1124', '5', '41', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 1124, 0, 0
                    , 210.00, 41, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '5', '41', '0', '4542', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '41', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1123', '43', '2022-08-20', '1', '0','1062',null,null,'2022-08-20 21:37:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '242', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4094';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1123, 0, 0
                    , 200.00, -43, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-43, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "43*2022-08-20*200.00," WHERE transferproductid = 4543;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '1', '43', '1', '4543', 'تحويل منتجات من المخزن', 'storemovementController.php', '285.00', '242', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1123', '5', '43', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 1123, 0, 0
                    , 200.00, 43, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+43, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '5', '43', '0', '4543', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '43', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1125', '34', '2022-08-20', '1', '0','1062',null,null,'2022-08-20 21:37:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '90', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4096';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1125, 0, 0
                    , 210.00, -34, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-34, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "34*2022-08-20*210.00," WHERE transferproductid = 4544;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '1', '34', '1', '4544', 'تحويل منتجات من المخزن', 'storemovementController.php', '124.00', '90', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1125', '5', '34', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 1125, 0, 0
                    , 210.00, 34, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+34, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '5', '34', '0', '4544', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '34', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1128', '28', '2022-08-20', '1', '0','1062',null,null,'2022-08-20 21:37:23',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '220', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4111';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1128, 0, 0
                    , 200.00, -28, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "28*2022-08-20*200.00," WHERE transferproductid = 4545;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '1', '28', '1', '4545', 'تحويل منتجات من المخزن', 'storemovementController.php', '248.00', '220', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1128', '5', '28', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 5, 1128, 0, 0
                    , 200.00, 28, 0, 0, 1, '2022-08-20 21:37:23')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:37:23' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '5', '28', '0', '4545', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '28', '1', '2022-08-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:23";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:37:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:37:24', '1', 'editshow', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:29";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:29", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:37:29', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:48";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:48", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:37:48', '5', 'add', '197.55.113.160', '', 'DESKTOP');
BEGIN;
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('1', '-978601.00', '1000', '1', 'ايصال دفع لمورد', '172', '-979601', '2022-08-20 21:37:29', '5', 'supplierPayedDeptController.php', 'جمعيه اودي', '0','3', '-1','1','1','1','1');
UPDATE supplier SET  suppliercurrentDebt = '-979601', userid = '5', supplierdate = '2022-08-20 21:37:48'   WHERE supplierid = '1';
UPDATE save SET  savecurrentvalue = '38595',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('39595.00','1000', '1', '3', 'ايصال دفع لمورد', '547', '38595', '2022-08-20 21:37:48', '5',  'supplierPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1000', '1000', '2022-08-20', '5', '0', '0', '2022-08-20 21:37:48','ايصال دفع لمورد ( مباشر ) ','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4466', '168', '1000', '','0');
UPDATE accountstree SET name = 'مباشر', customName = 'مباشر', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '7', mydate = '2021-12-11', itemtype2 = '1', theValue = '-979601', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '168';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4466', '137', '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 = '-606625', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
UPDATE supplierdebtchange SET supplierid = '1', supplierdebtchangebefore = '-978601.00', supplierdebtchangeamount = '1000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '172', supplierdebtchangeafter = '-979601.00', supplierdebtchangedate = '2022-08-20 21:37:29', userid = '5', tablename = 'supplierPayedDeptController.php', comment = 'جمعيه اودي', dailyentryid = '4466',saveid = '3',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE supplierdebtchangeid = '547';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:49";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:37:49', '5', 'sucess', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:50";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:50", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-08-20 21:37:50', '5', 'show', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:51";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2022-08-20 21:37:51', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:07:54";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:37:54", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:37:54', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:08:05";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:38:05", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:38:05', '5', 'showDetail', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:08:19";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:38:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:38:19', '1', '', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:08:46";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:38:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:38:46', '5', 'addsellBill', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:09:45";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:39:45", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 21:39:45', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:10:00";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:40:00", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 21:40:00', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:10:26";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:40:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:40:26', '1', 'add', '156.210.34.51', '', '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(1063,1,6,1122,37,'2022-08-20',1,0, '' ,0,0,0,0,0,'2022-08-20 21:40:26',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4093';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1122, 0, 0
                    , 210.00, -37, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-37, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "37*2022-08-20*210.00," WHERE transferproductid = 4546;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '1', '37', '1', '4546', 'تحويل منتجات من المخزن', 'storemovementController.php', '44.00', '7', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1122', '6', '37', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1122, 0, 0
                    , 210.00, 37, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+37, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1122', '6', '37', '0', '4546', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '37', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1124', '41', '2022-08-20', '1', '0','1063',null,null,'2022-08-20 21:40:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '45', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4095';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1124, 0, 0
                    , 210.00, -41, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "41*2022-08-20*210.00," WHERE transferproductid = 4547;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '1', '41', '1', '4547', 'تحويل منتجات من المخزن', 'storemovementController.php', '86.00', '45', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1124', '6', '41', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1124, 0, 0
                    , 210.00, 41, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+41, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1124', '6', '41', '0', '4547', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '41', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1123', '42', '2022-08-20', '1', '0','1063',null,null,'2022-08-20 21:40:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '200', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4094';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1123, 0, 0
                    , 200.00, -42, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-42, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "42*2022-08-20*200.00," WHERE transferproductid = 4548;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '1', '42', '1', '4548', 'تحويل منتجات من المخزن', 'storemovementController.php', '242.00', '200', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1123', '6', '42', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1123, 0, 0
                    , 200.00, 42, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+42, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1123', '6', '42', '0', '4548', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '42', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1125', '32', '2022-08-20', '1', '0','1063',null,null,'2022-08-20 21:40:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '58', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4096';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1125, 0, 0
                    , 210.00, -32, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2022-08-20*210.00," WHERE transferproductid = 4549;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '1', '32', '1', '4549', 'تحويل منتجات من المخزن', 'storemovementController.php', '90.00', '58', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1125', '6', '32', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1125, 0, 0
                    , 210.00, 32, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '6', '32', '0', '4549', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '32', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1128', '28', '2022-08-20', '1', '0','1063',null,null,'2022-08-20 21:40:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '192', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '4111';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1128, 0, 0
                    , 200.00, -28, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "28*2022-08-20*200.00," WHERE transferproductid = 4550;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '1', '28', '1', '4550', 'تحويل منتجات من المخزن', 'storemovementController.php', '220.00', '192', '1', '2022-08-20','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1128', '6', '28', '1', '2022-08-20');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1128, 0, 0
                    , 200.00, 28, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1128', '6', '28', '0', '4550', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '28', '1', '2022-08-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1062', '9', '2022-08-20', '1', '0','1063',null,null,'2022-08-20 21:40:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-194', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3723';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 1, 1062, 0, 0
                    , 265.00, -9, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyprice = 265.00,
                        buyQuantity =buyQuantity+-9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2022-08-20*265.00," WHERE transferproductid = 4551;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '1', '9', '1', '4551', 'تحويل منتجات من المخزن', 'storemovementController.php', '-185.00', '-194', '1', '2022-08-20','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2022-08-20' WHERE storedetailid = '3746';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-08-20', 6, 1062, 0, 0
                    , 265.00, 9, 0, 0, 1, '2022-08-20 21:40:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-08-20 21:40:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '6', '9', '0', '4551', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '5.00', '14', '1', '2022-08-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:10:27";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:40:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-08-20 21:40:27', '1', 'editshow', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:12:00";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:42:00", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 21:42:00', '5', 'add', '197.55.113.160', '', '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 =11817
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(260,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '1120' , clientdate = '2022-08-20 21:42:00', userid = '5' WHERE clientid = '260';
UPDATE client SET  inUse = 0 where clientid = 260;
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 ('260','1520.00','400','1','ايصال تحصيل (( قبض من عميل ))','11817', '1120', '2022-08-20 21:40:00', '5', 'clientPayedDeptController.php', '   ', '400', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '38995',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('38595.00','400', '0', '3', 'ايصال تحصيل (( قبض من عميل ))', '11817', '38995', '2022-08-20 21:42:00', '5',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '400', '400', '2022-08-20', '5', '0', '0', '2022-08-20 21:42:00','اضافة ايصال سداد للعميل ام هنا المحل القديم','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4467', '137', '400', '','0');
UPDATE accountstree SET name = 'خزينة رائد', customName = 'خزينة رائد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-606225', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4467', '340', '400', '','0');
UPDATE accountstree SET name = 'ام هنا المحل القديم', customName = 'ام هنا المحل القديم', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '5', mydate = '2022-08-06', itemtype2 = '1', theValue = '-400', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '340';
UPDATE clientdebtchange SET clientid = '260', clientdebtchangebefore = '1520.00', clientdebtchangeamount = '400.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '11817', clientdebtchangeafter = '1120.00', clientdebtchangedate = '2022-08-20 21:40:00', userid = '5', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '400.00',discount='', reciptid=null, dailyentryid = '4467',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '11817';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:12:00";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:42:00", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 21:42:00', '5', 'sucess', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:12:02";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:42:02", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-08-20 21:42:02', '5', 'show', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:12:12";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:42:12", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:42:12', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:13:14";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 21:43:14", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 21:43:14', '5', 'showDetail', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:27:26";
UPDATE user SET loginip = "156.210.34.51", lastactivetime = "2022-08-20 21:57:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 21:57:26', '1', 'addsellBill', '156.210.34.51', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:55:54";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 22:25:54", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 22:25:54', '5', '', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 18:55:59";
UPDATE user SET loginip = "197.55.113.160", lastactivetime = "2022-08-20 22:25:59", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 22:25:59', '5', 'showDetail', '197.55.113.160', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:19:34";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:49:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 22:49:34', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:19:41";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:49:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 22:49:41', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:21:59";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:51:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 22:51:59', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:24:56";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:54:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 22:54:56', '7', 'addAndRetuen', '197.192.206.104', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06301496f64660
-- ----------------------------------------------------------------------------------------------------

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 ('2022-08-20 22:51:59', '06301496f64660', '1', '0.00', '0', '0', '1', '740', '740', '740', '0', '5', '2022-08-20 22:54:56', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','740','0','','0','0','740','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','اضافة فاتورة مبيعات','7821', '0', '2022-08-20 22:54:56', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '740', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('170','01051', '7821', '1', '1051', '1', '220', '220', '0', '', '1', '2022-08-20 22:54:56', '1051', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 23456;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1051, '2022-08-20', 220, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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, '2022-08-20', 220, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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 = '2022-08-20 22:54:56' WHERE storedetailid = '3730';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1051', '5', '1', '1', '7821', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '7', '2022-08-20 22:54:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8694;
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 ('200','01118', '7821', '1', '1118', '1', '250', '250', '0', '', '1', '2022-08-20 22:54:56', '1118', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','8694-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 23457;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1118, '2022-08-20', 250, 400, 200
                    , 300, 200, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-08-20', 250, 400, 200
                    , 300, 200, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2022-08-20 22:54:56' WHERE storedetailid = '4047';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1118', '5', '1', '1', '7821', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '7', '2022-08-20 22:54:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9044;
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 ('220','01074', '7821', '1', '1074', '1', '270', '270', '0', '', '1', '2022-08-20 22:54:56', '1074', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','9044-1,');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 23458;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1074, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , 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, '2022-08-20', 270, 220, 220
                    , 220, 220, 220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '39', userid = '7', storedetaildate = '2022-08-20 22:54:56' WHERE storedetailid = '3924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1074', '5', '1', '1', '7821', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40.00', '39', '7', '2022-08-20 22:54:56','0','0');
UPDATE save SET  savecurrentvalue = '1535',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('795.00','740', '0', '5', 'اضافة فاتورة مبيعات', '7821', '1535', '2022-08-20 22:54:56', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-08-20', 740, 790, 590
                    , 690, 590, 690, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , 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, '2022-08-20', 740, 790, 590
                    , 690, 590, 690, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , 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, 740, 790, 590
                    , 690, 590, 690, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+740, netSellCostBuyPrice = netSellCostBuyPrice+790
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+590
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+690
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+590
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+690
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06301496f64660 and sellbillId = 7821 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:24:57";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:54:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-08-20 22:54:57', '7', 'addsellBill', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:25:08";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:55:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 22:55:08', '7', '', '197.192.206.104', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-08-20 19:26:50";
UPDATE user SET loginip = "197.192.206.104", lastactivetime = "2022-08-20 22:56:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-08-20 22:56:50', '7', 'showDetail', '197.192.206.104', '', 'DESKTOP');
