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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 06:19:47";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 09:49:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 09:49:47', '4', '', '197.61.145.83', '', '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-10-13',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-10-13 06:19:47";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 06:41:19";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 10:11:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 10:11:19', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 06:42:18";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 10:12:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 10:12:18', '4', 'addAndRetuen', '197.61.145.83', '', '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 06347c827b8e98
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(137,@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-10-13 10:11:19', '06347c827b8e98', '137', '850.00', '1115', '0', '1', '265', '265', '0', '265', '7', '2022-10-13 10:12:18', '', '4', '0', 'جلال ابو حلا', '7', '1', '3', '0', 'جلال ابو حلا', '1' ,'0','','','','','-1','0','0','0','0','0','265','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '1115', userid = '4' WHERE clientid = '137';
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 ('137','850.00','265','0','اضافة فاتورة مبيعات','8692', '1115', '2022-10-13 10:12:18', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '265', '0', null, '0', null, null,'', '0','1','1','265','1');
UPDATE client SET  inUse = 0 where clientid = 137;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9380;
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','01129', '8692', '1', '1129', '1', '265', '265', '0', '', '0', '2022-10-13 10:12:18', '1129', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','9380-1,');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
                where sellbilldetailid = 25823;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1129, '2022-10-13', 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 (7, '2022-10-13', 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 = '7', userid = '4', storedetaildate = '2022-10-13 10:12:18' WHERE storedetailid = '4146';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1129', '7', '1', '1', '8692', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '4', '2022-10-13 10:12:18','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (137, '2022-10-13', 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;
 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 06347c827b8e98 and sellbillId = 8692 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 06:42:19";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 10:12:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 10:12:19', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 06:42:22";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 10:12:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 10:12:22', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:03:14";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:33:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:33:15', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:05:52";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:35:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:35:52', '4', 'addAndRetuen', '197.61.145.83', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06347db5b5cfa0
-- ----------------------------------------------------------------------------------------------------

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-10-13 11:33:15', '06347db5b5cfa0', '1', '0.00', '0', '0', '1', '465', '465', '-465', '0', '7', '2022-10-13 11:35:52', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-465','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','اضافة فاتورة مردوات مبيعات','3124', '0', '2022-10-13 11:35:53', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '465', '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', '3124', '1', '1062', '1', '265.00', '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 = 6805;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1062, '2022-10-13', 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-10-13', 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 = '40', userid = '4', storedetaildate = '2022-10-13 11:35:53' WHERE storedetailid = '3726';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1062', '7', '1', '0', '3124', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '39.00', '40', '4', '2022-10-13 11:35:53','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', '3124', '1', '1047', '1', '200', '200', '0', '', '0', '0', '1047', '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 = 6806;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1047, '2022-10-13', 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-10-13', 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 = '0', userid = '4', storedetaildate = '2022-10-13 11:35:53' WHERE storedetailid = '3643';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1047', '7', '1', '0', '3124', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-1.00', '0', '4', '2022-10-13 11:35:53','0','0');
UPDATE save SET  savecurrentvalue = '4347',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4812.00','465', '1', '7', 'اضافة فاتورة مردوات مبيعات', '3124', '4347', '2022-10-13 11:35: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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 465, 465, 465, 465
                    , 465, 465, 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+465, returnSellCostBuyPrice = returnSellCostBuyPrice+465, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+465
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+465, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+465
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+465
                        , 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 465, 465, 465, 465
                    , 465, 465, 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+465, returnSellCostBuyPrice = returnSellCostBuyPrice+465, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+465
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+465, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+465
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+465
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -465, -465, -465
                    , -465, -465, -465, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-465, netSellCostBuyPrice = netSellCostBuyPrice+-465
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-465
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-465
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-465
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-465
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06347db5b5cfa0 and sellbillId = 3124 and returnsellbillId = 3124
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:05:53";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:35:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:35:53', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:05:55";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:35:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 11:35:55', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:05:58";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:35:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-10-13 11:35:58', '4', 'showDetail', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:06:39";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:36:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:36:39', '4', 'addAndRetuen', '197.61.145.83', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06347c866a85ab
-- ----------------------------------------------------------------------------------------------------

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-10-13 10:12:22', '06347c866a85ab', '1', '0.00', '0', '0', '1', '1260', '1260', '1260', '0', '7', '2022-10-13 11:36:40', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','1260','0','','0','0','1260','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '4' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','8693', '0', '2022-10-13 11:36:40', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1260', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 1492;
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','00513', '8693', '1', '513', '3', '200', '600', '0', '', '0', '2022-10-13 11:36:40', '513', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','1492-3,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 25824;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (513, '2022-10-13', 600, 630, 630
                    , 630, 630, 630, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2022-10-13', 600, 630, 630
                    , 630, 630, 630, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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;
UPDATE storedetail SET  productquantity = '12', userid = '4', storedetaildate = '2022-10-13 11:36:40' WHERE storedetailid = '1297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '7', '3', '1', '8693', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '12', '4', '2022-10-13 11:36:40','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 ('210','00563', '8693', '1', '563', '1', '220', '220', '0', '', '0', '2022-10-13 11:36:40', '563', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 25825;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (563, '2022-10-13', 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-10-13', 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 = '4', userid = '4', storedetaildate = '2022-10-13 11:36:40' WHERE storedetailid = '1553';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('563', '7', '1', '1', '8693', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '4', '2022-10-13 11:36:40','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 ('220','01011', '8693', '1', '1011', '2', '220', '440', '0', '', '0', '2022-10-13 11:36:40', '1011', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
                where sellbilldetailid = 25826;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1011, '2022-10-13', 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-10-13', 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 = '7', userid = '4', storedetaildate = '2022-10-13 11:36:40' WHERE storedetailid = '3808';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1011', '7', '2', '1', '8693', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '7', '4', '2022-10-13 11:36:40','0','0');
UPDATE save SET  savecurrentvalue = '5607',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4347.00','1260', '0', '7', 'اضافة فاتورة مبيعات', '8693', '5607', '2022-10-13 11:36:40', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 1260, 1280, 1280
                    , 1280, 1280, 1280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1280
                            , 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-10-13', 1260, 1280, 1280
                    , 1280, 1280, 1280, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+1280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1260, 1280, 1280
                    , 1280, 1280, 1280, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1260, netSellCostBuyPrice = netSellCostBuyPrice+1280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06347c866a85ab and sellbillId = 8693 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:06:40";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:36:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:36:40', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:06:46";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:36:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 11:36:47', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:06:52";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:36:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:36:52', '4', 'showDetail', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:22:30";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 11:52:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 11:52:31', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:35:55";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:05:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:05:55', '4', 'addAndRetuen', '197.61.145.83', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06347dfdf21e34
-- ----------------------------------------------------------------------------------------------------

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-10-13 11:52:31', '06347dfdf21e34', '1', '0.00', '0', '0', '1', '220', '220', '220', '0', '7', '2022-10-13 12:05:56', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','220','0','','0','0','220','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','8694', '0', '2022-10-13 12:05:56', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '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 ('210','01125', '8694', '1', '1125', '1', '220', '220', '0', '', '0', '2022-10-13 12:05:56', '1125', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 25827;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1125, '2022-10-13', 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-10-13', 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 = '5', userid = '4', storedetaildate = '2022-10-13 12:05:56' WHERE storedetailid = '4102';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1125', '7', '1', '1', '8694', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '4', '2022-10-13 12:05:56','0','0');
UPDATE save SET  savecurrentvalue = '5827',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5607.00','220', '0', '7', 'اضافة فاتورة مبيعات', '8694', '5827', '2022-10-13 12:05:56', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 220, 210, 210
                    , 210, 210, 210, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, netSellCostBuyPrice = netSellCostBuyPrice+210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06347dfdf21e34 and sellbillId = 8694 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:35:56";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:05:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:05:56', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:36:23";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:06:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 12:06:23', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:36:26";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:06:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:06:26', '4', 'showDetail', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:37:58";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:07:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:07:58', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:43:00";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:13:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:13:00', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:43:27";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:13:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:13:27', '4', 'addsellBill', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:43:33";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:13:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 12:13:33', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 08:45:16";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:15:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:15:16', '4', 'addsellBill', '197.61.145.83', '', '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-10-13 09:07:45";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 12:37:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 12:37:45', '7', '', '197.192.205.152', '', '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-10-13 09:07:45";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 09:20:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 12:50:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:50:08', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 09:29:34";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:59:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 12:59:34', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 09:29:48";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 12:59:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 12:59:48', '4', 'addsellBill', '197.61.145.83', '', '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-10-13 10:31:21";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 14:01:22", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 14:01:22', '5', '', '197.55.173.253', '', '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-10-13 10:31:22";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 10:31:24";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 14:01:24", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 14:01:24', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:03:52";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 15:33:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 15:33:53', '7', 'addsellBill', '197.192.205.152', '', '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-10-13 12:47:14";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:17:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 16:17:14', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:47: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-10-13 12:52:21";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:22:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 16:22:21', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:52:30";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:22:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 16:22:30', '1', 'show', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:52:48";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:22:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-10-13 16:22:48', '1', 'showDetail', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:52:49";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:22:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 16:22:50', '1', 'showDetail', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:52:51";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:22:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 16:22:51', '1', 'showDetail', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 12:53:29";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 16:23:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 16:23:29', '1', 'addsellBill', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 13:03:45";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 16:33:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 16:33:45', '7', 'addsellBill', '197.192.205.152', '', '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-10-13 13:18:06";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 16:48:06", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 16:48:07', '4', '', '197.61.145.83', '', '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-10-13 13:18:07";
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-10-13 14:10:32";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:32', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:39";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:40:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 17:40:39', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:41";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:41', '4', 'add', '197.61.145.83', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'قبض روني بالنسبه', '', '900', '2022-10-13', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '4927',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5827.00','900', '1', '7', 'إضافة مصروف', '1907', '4927', '2022-10-13 17:40:41', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '900', '900', '2022-10-13', '4', '0', '0', '2022-10-13 17:40:41','اضافة اسم مصروف( قبض روني بالنسبه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4930', '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 = '-779890', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4930', '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 = '-929660', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'قبض روني بالنسبه', expensesdetails = '', expensesValue = '900.00', expensesdate = '2022-10-13', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4930', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1907';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:41";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:41', '4', 'sucess', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:43";
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:43";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:40:43", deviceType = "DESKTOP" WHERE userid = 7;
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:40:43', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:43', '4', 'show', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:43";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:43', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:52";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:52', '4', 'add', '197.61.145.83', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'قبض العميد بالنسبه', '', '900', '2022-10-13', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '4027',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4927.00','900', '1', '7', 'إضافة مصروف', '1908', '4027', '2022-10-13 17:40:52', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '900', '900', '2022-10-13', '4', '0', '0', '2022-10-13 17:40:52','اضافة اسم مصروف( قبض العميد بالنسبه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4931', '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 = '-780790', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4931', '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 = '-930560', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'قبض العميد بالنسبه', expensesdetails = '', expensesValue = '900.00', expensesdate = '2022-10-13', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4931', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1908';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:52";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:52', '4', 'sucess', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:54";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:40:54', '4', 'show', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:10:56";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:40:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 17:40:56', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:13:50";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:43:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:43:50', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06348317b7538a
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:40:43', '06348317b7538a', '1', '0.00', '0', '0', '1', '200', '200', '200', '0', '5', '2022-10-13 17:43:50', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','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','اضافة فاتورة مبيعات','8695', '0', '2022-10-13 17:43:50', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8112;
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','01090', '8695', '1', '1090', '1', '200.00', '200', '0', '', '0', '2022-10-13 17:43:50', '1090', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8112-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 25828;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1090, '2022-10-13', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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-10-13', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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 = '6', userid = '7', storedetaildate = '2022-10-13 17:43:50' WHERE storedetailid = '3922';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1090', '5', '1', '1', '8695', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '7', '2022-10-13 17:43:50','0','0');
UPDATE save SET  savecurrentvalue = '1410',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1210.00','200', '0', '5', 'اضافة فاتورة مبيعات', '8695', '1410', '2022-10-13 17:43: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-10-13', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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-10-13', 200, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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, 200, 200, 200
                    , 200, 200, 200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06348317b7538a and sellbillId = 8695 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:13:50";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:43:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:43:50', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:14:27";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:44:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:44:28', '7', 'addsellBill', '197.192.205.152', '', '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-10-13 14:15:38";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:45:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 17:45:39', '4', '', '197.61.145.83', '', '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-10-13 14:15: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-10-13 14:15:43";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:45:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 17:45:43', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:01";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:46:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:46:01', '7', 'addAndRetuen', '197.192.205.152', '', '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 06348325c5b7bf
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(253,@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-10-13 17:44:28', '06348325c5b7bf', '253', '0.00', '-370', '0', '1', '370', '370', '0', '-370', '5', '2022-10-13 17:46:01', '', '7', '0', 'ام شيماء خورشيد','5', '1', '5', '0', 'ام شيماء خورشيد', '2', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-370', userid = '7' WHERE clientid = '253';
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 ('253','0.00','370','1','اضافة فاتورة مردوات مبيعات','3125', '-370', '2022-10-13 17:46:01', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','370','1');
UPDATE client SET  inUse = 0 where clientid = 253;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('400.00', '00572', '3125', '1', '572', '1', '200', '200', '0', '', '0', '0', '572', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 302.50, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 302.50
                where returnsellbilldetailid = 6807;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (572, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 400, 210, 302.5
                    , 210, 302.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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+302.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+302.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 (5, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 400, 210, 302.5
                    , 210, 302.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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+302.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+302.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '7', storedetaildate = '2022-10-13 17:46:01' WHERE storedetailid = '2255';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '5', '1', '0', '3125', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '12.00', '13', '7', '2022-10-13 17:46:01','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', '00474', '3125', '1', '474', '1', '170.00', '170', '0', '', '0', '0', '474', '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 = 6808;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (474, '2022-10-13', 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 (5, '2022-10-13', 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 = '56', userid = '7', storedetaildate = '2022-10-13 17:46:02' WHERE storedetailid = '1886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('474', '5', '1', '0', '3125', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '55.00', '56', '7', '2022-10-13 17:46:02','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 570, 380, 472.5
                    , 380, 472.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+570, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+380
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+472.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+380
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+472.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (253, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 370, 570, 380, 472.5
                    , 380, 472.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+570, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+380
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+472.5, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+380
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+472.5
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -370, -570, -380
                    , -472.5, -380, -472.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-370, netSellCostBuyPrice = netSellCostBuyPrice+-570
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-472.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-472.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06348325c5b7bf and sellbillId = 3125 and returnsellbillId = 3125
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:02";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:46:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:46:02', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:46:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:46:08', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:11";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:46:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:46:11', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:23";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:46:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:46:23', '4', 'add', '197.61.145.83', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'شحن كهرباء', '', '500', '2022-10-13', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3527',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4027.00','500', '1', '7', 'إضافة مصروف', '1909', '3527', '2022-10-13 17:46:23', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '500', '500', '2022-10-13', '4', '0', '0', '2022-10-13 17:46:23','اضافة اسم مصروف( شحن كهرباء )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4932', '160', '500', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-781290', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4932', '141', '500', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-931060', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'شحن كهرباء', expensesdetails = '', expensesValue = '500.00', expensesdate = '2022-10-13', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '4932', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1909';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:23";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:46:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:46:23', '4', 'sucess', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:24";
UPDATE user SET loginip = "197.61.145.83", lastactivetime = "2022-10-13 17:46:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 17:46:24', '4', '', '197.61.145.83', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:30";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:46:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:46:30', '7', 'addAndRetuen', '197.192.205.152', '', '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 0634832c04439a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(253,@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-10-13 17:46:08', '0634832c04439a', '253', '-370.00', '-185', '0', '1', '185', '185', '0', '185', '5', '2022-10-13 17:46:31', '', '7', '0', 'ام شيماء خورشيد', '5', '1', '3', '0', 'ام شيماء خورشيد', '1' ,'0','','','','','-1','0','0','0','0','0','185','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '-185', userid = '7' WHERE clientid = '253';
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 ('253','-370.00','185','0','اضافة فاتورة مبيعات','8696', '-185', '2022-10-13 17:46:31', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '185', '0', null, '0', null, null,'', '0','1','1','185','1');
UPDATE client SET  inUse = 0 where clientid = 253;
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','00431', '8696', '1', '431', '1', '185.00', '185', '0', '', '0', '2022-10-13 17:46:31', '431', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 25829;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (431, '2022-10-13', 185, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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-10-13', 185, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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 = '1', userid = '7', storedetaildate = '2022-10-13 17:46:31' WHERE storedetailid = '3033';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('431', '5', '1', '1', '8696', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2.00', '1', '7', '2022-10-13 17:46:31','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 185, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (253, '2022-10-13', 185, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 185, 170, 170
                    , 170, 170, 170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+185, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634832c04439a and sellbillId = 8696 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:16:31";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:46:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:46:31', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:00";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:00', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634832d778965
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:46:31', '0634832d778965', '1', '0.00', '0', '0', '1', '200', '200', '200', '0', '5', '2022-10-13 17:47:00', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','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','اضافة فاتورة مبيعات','8697', '0', '2022-10-13 17:47:00', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 3348;
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','00572', '8697', '1', '572', '1', '200.00', '200', '0', '', '0', '2022-10-13 17:47:00', '572', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','3348-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 302.50, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 302.50
                where sellbilldetailid = 25830;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (572, '2022-10-13', 200, 400, 210
                    , 302.5, 210, 302.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 200, 400, 210
                    , 302.5, 210, 302.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '7', storedetaildate = '2022-10-13 17:47:00' WHERE storedetailid = '2255';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('572', '5', '1', '1', '8697', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '7', '2022-10-13 17:47:00','0','0');
UPDATE save SET  savecurrentvalue = '1610',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1410.00','200', '0', '5', 'اضافة فاتورة مبيعات', '8697', '1610', '2022-10-13 17:47:00', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 200, 400, 210
                    , 302.5, 210, 302.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 200, 400, 210
                    , 302.5, 210, 302.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 200, 400, 210
                    , 302.5, 210, 302.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+302.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+302.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634832d778965 and sellbillId = 8697 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:00";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:00', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:05";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:05', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:17";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:17', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634832f92fafe
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:47:05', '0634832f92fafe', '1', '0.00', '0', '0', '1', '200', '200', '-200', '0', '5', '2022-10-13 17:47:17', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-200','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','اضافة فاتورة مردوات مبيعات','3126', '0', '2022-10-13 17:47:17', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '200', '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 ('385.00', '00637', '3126', '1', '637', '1', '200.00', '200', '0', '', '2', '0', '637', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 285.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 285.00
                where returnsellbilldetailid = 6809;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (637, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 385, 185, 285
                    , 185, 285, 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+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+185
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+285, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+185
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+285
                            , 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 385, 185, 285
                    , 185, 285, 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+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+185
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+285, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+185
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+285
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '29', userid = '7', storedetaildate = '2022-10-13 17:47:17' WHERE storedetailid = '2264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('637', '5', '1', '0', '3126', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '28.00', '29', '7', '2022-10-13 17:47:17','0','0');
UPDATE save SET  savecurrentvalue = '1410',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1610.00','200', '1', '5', 'اضافة فاتورة مردوات مبيعات', '3126', '1410', '2022-10-13 17:47:17', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 385, 185, 285
                    , 185, 285, 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+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+185
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+285, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+185
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+285
                        , 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 385, 185, 285
                    , 185, 285, 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+385, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+185
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+285, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+185
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+285
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -200, -385, -185
                    , -285, -185, -285, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-200, netSellCostBuyPrice = netSellCostBuyPrice+-385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-185
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-285
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-185
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-285
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634832f92fafe and sellbillId = 3126 and returnsellbillId = 3126
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:18";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:18", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:18', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:17:24";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:47:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:47:24', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:18:16";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:48:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:48:16', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06348330ca2668
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:47:24', '06348330ca2668', '1', '0.00', '0', '0', '1', '180', '180', '180', '0', '5', '2022-10-13 17:48:16', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','180','0','','0','0','180','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','اضافة فاتورة مبيعات','8698', '0', '2022-10-13 17:48:16', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '180', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9342;
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', '8698', '1', '474', '1', '180.00', '180', '0', '', '2', '2022-10-13 17:48:16', '474', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','9342-1,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 25831;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (474, '2022-10-13', 180, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, 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-10-13', 180, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, 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 = '55', userid = '7', storedetaildate = '2022-10-13 17:48:17' WHERE storedetailid = '1886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('474', '5', '1', '1', '8698', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56.00', '55', '7', '2022-10-13 17:48:17','0','0');
UPDATE save SET  savecurrentvalue = '1590',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1410.00','180', '0', '5', 'اضافة فاتورة مبيعات', '8698', '1590', '2022-10-13 17:48:17', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 180, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 180, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 180, 170, 170
                    , 170, 170, 170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+180, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06348330ca2668 and sellbillId = 8698 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:18:17";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:48:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:48:17', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:18:21";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:48:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:48:21', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:18:42";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:48:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:48:42', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063483345dd680
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:48:21', '063483345dd680', '1', '0.00', '0', '10', '1', '260', '250', '-250', '0', '5', '2022-10-13 17:48:42', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-250','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','اضافة فاتورة مردوات مبيعات','3127', '0', '2022-10-13 17:48:42', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '250', '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', '01111', '3127', '1', '1111', '1', '260', '260', '0', '', '1', '0', '1111', '0.00', '0','5','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where returnsellbilldetailid = 6810;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1111, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 270, 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+270, 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 (5, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 270, 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+270, returnSellCostBuyPrice = returnSellCostBuyPrice+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '7', storedetaildate = '2022-10-13 17:48:42' WHERE storedetailid = '3986';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1111', '5', '1', '0', '3127', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '16.00', '17', '7', '2022-10-13 17:48:42','0','0');
UPDATE save SET  savecurrentvalue = '1340',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1590.00','250', '1', '5', 'اضافة فاتورة مردوات مبيعات', '3127', '1340', '2022-10-13 17:48:42', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 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+250, 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 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+250, 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, -250, -210, -210
                    , -210, -210, -210, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-250, netSellCostBuyPrice = netSellCostBuyPrice+-210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063483345dd680 and sellbillId = 3127 and returnsellbillId = 3127
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:18:42";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:48:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:48:42', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:19:50";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:49:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:49:50', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:20:29";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:50:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:50:29', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06348339ec0aee
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:49:50', '06348339ec0aee', '1', '0.00', '0', '0', '1', '180', '180', '180', '0', '5', '2022-10-13 17:50:30', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','180','0','','0','0','180','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','اضافة فاتورة مبيعات','8699', '0', '2022-10-13 17:50:30', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '180', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 704;
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','00387', '8699', '1', '387', '1', '180', '180', '0', '', '1', '2022-10-13 17:50:30', '387', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','704-1,');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 162.50, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 162.50
                where sellbilldetailid = 25832;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (387, '2022-10-13', 180, 150, 175
                    , 162.5, 175, 162.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+162.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+162.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 180, 150, 175
                    , 162.5, 175, 162.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+162.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+162.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '7', storedetaildate = '2022-10-13 17:50:30' WHERE storedetailid = '903';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('387', '5', '1', '1', '8699', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12.00', '11', '7', '2022-10-13 17:50:30','0','0');
UPDATE save SET  savecurrentvalue = '1520',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1340.00','180', '0', '5', 'اضافة فاتورة مبيعات', '8699', '1520', '2022-10-13 17:50:30', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 180, 150, 175
                    , 162.5, 175, 162.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+162.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+162.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 180, 150, 175
                    , 162.5, 175, 162.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+162.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+162.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 180, 150, 175
                    , 162.5, 175, 162.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+180, netSellCostBuyPrice = netSellCostBuyPrice+150
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+175
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+162.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+175
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+162.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06348339ec0aee and sellbillId = 8699 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:20:30";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:50:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:50:30', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:20:53";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:50:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:50:53', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634833c6b1522
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:50:30', '0634833c6b1522', '1', '0.00', '0', '0', '1', '255', '255', '255', '0', '5', '2022-10-13 17:50:54', '', '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','اضافة فاتورة مبيعات','8700', '0', '2022-10-13 17:50:54', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '255', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7058;
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 ('290','01021', '8700', '1', '1021', '1', '255.00', '255', '0', '', '2', '2022-10-13 17:50:54', '1021', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','7058-1,');
UPDATE sellbilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 263.75, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 263.75
                where sellbilldetailid = 25833;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1021, '2022-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , 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-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '31', userid = '7', storedetaildate = '2022-10-13 17:50:54' WHERE storedetailid = '3562';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1021', '5', '1', '1', '8700', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32.00', '31', '7', '2022-10-13 17:50:54','0','0');
UPDATE save SET  savecurrentvalue = '1775',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1520.00','255', '0', '5', 'اضافة فاتورة مبيعات', '8700', '1775', '2022-10-13 17:50:54', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , 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-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , 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, 245, 290
                    , 263.75, 290, 263.75, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+255, netSellCostBuyPrice = netSellCostBuyPrice+245
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+290
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+263.75
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+290
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+263.75
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634833c6b1522 and sellbillId = 8700 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:20:54";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:50:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:50:54', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:21:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:51:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:51:08', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634833de90b83
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:50:54', '0634833de90b83', '1', '0.00', '0', '5', '1', '205', '200', '200', '0', '5', '2022-10-13 17:51:08', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','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','اضافة فاتورة مبيعات','8701', '0', '2022-10-13 17:51:08', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 6410;
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', '8701', '1', '643', '1', '205', '205', '0', '', '1', '2022-10-13 17:51:08', '643', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','6410-1,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 25834;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (643, '2022-10-13', 200, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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-10-13', 200, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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 = '16', userid = '7', storedetaildate = '2022-10-13 17:51:08' WHERE storedetailid = '2270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('643', '5', '1', '1', '8701', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '7', '2022-10-13 17:51:08','0','0');
UPDATE save SET  savecurrentvalue = '1975',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1775.00','200', '0', '5', 'اضافة فاتورة مبيعات', '8701', '1975', '2022-10-13 17:51:08', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 200, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 200, 170, 170
                    , 170, 170, 170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 200, 170, 170
                    , 170, 170, 170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634833de90b83 and sellbillId = 8701 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:21:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:51:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:51:09', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:22:01";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:52:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:52:01', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634833ed1cf60
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:51:09', '0634833ed1cf60', '1', '0.00', '0', '35', '1', '745', '710', '710', '0', '5', '2022-10-13 17:52:01', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','710','0','','0','0','710','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','اضافة فاتورة مبيعات','8702', '0', '2022-10-13 17:52:01', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '710', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8108;
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 ('235','01091', '8702', '1', '1091', '1', '285', '285', '0', '', '1', '2022-10-13 17:52:02', '1091', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','8108-1,');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
                where sellbilldetailid = 25835;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1091, '2022-10-13', 271.610738255, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+271.610738255, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13', 271.610738255, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+271.610738255, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13 17:52:02' WHERE storedetailid = '3920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1091', '5', '1', '1', '8702', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2022-10-13 17:52:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 6884;
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 ('235','01014', '8702', '1', '1014', '1', '275', '275', '0', '', '1', '2022-10-13 17:52:02', '1014', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','6884-1,');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
                where sellbilldetailid = 25836;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1014, '2022-10-13', 262.080536913, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.080536913, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13', 262.080536913, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.080536913, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '7', storedetaildate = '2022-10-13 17:52:02' WHERE storedetailid = '3507';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1014', '5', '1', '1', '8702', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '7', '2022-10-13 17:52:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 5162;
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 ('155','00107', '8702', '1', '107', '1', '185', '185', '0', '', '1', '2022-10-13 17:52:02', '107', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','5162-1,');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 150.00
                where sellbilldetailid = 25837;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (107, '2022-10-13', 176.308724832, 145, 155
                    , 150, 155, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+176.308724832, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-10-13', 176.308724832, 145, 155
                    , 150, 155, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+176.308724832, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '7', storedetaildate = '2022-10-13 17:52:02' WHERE storedetailid = '3031';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('107', '5', '1', '1', '8702', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '7', '2022-10-13 17:52:02','0','0');
UPDATE save SET  savecurrentvalue = '2685',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1975.00','710', '0', '5', 'اضافة فاتورة مبيعات', '8702', '2685', '2022-10-13 17:52:02', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 710, 615, 625
                    , 620, 625, 620, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+710, sellCostBuyPrice =sellCostBuyPrice+615
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , 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-10-13', 710, 615, 625
                    , 620, 625, 620, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+710, sellCostBuyPrice =sellCostBuyPrice+615
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+625, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+625, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , 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, 710, 615, 625
                    , 620, 625, 620, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+710, netSellCostBuyPrice = netSellCostBuyPrice+615
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+625
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+620
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+625
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+620
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634833ed1cf60 and sellbillId = 8702 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:22:02";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:52:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:52:02', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:22:24";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:52:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:52:24', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063483422ce300
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:52:02', '063483422ce300', '1', '0.00', '0', '0', '1', '185', '185', '185', '0', '5', '2022-10-13 17:52:24', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','185','0','','0','0','185','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','اضافة فاتورة مبيعات','8703', '0', '2022-10-13 17:52:24', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '185', '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 ('165','00479', '8703', '1', '479', '1', '185.00', '185', '0', '', '0', '2022-10-13 17:52:24', '479', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
                where sellbilldetailid = 25838;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (479, '2022-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-10-13 17:52:24' WHERE storedetailid = '893';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('479', '5', '1', '1', '8703', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '7', '2022-10-13 17:52:24','0','0');
UPDATE save SET  savecurrentvalue = '2870',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2685.00','185', '0', '5', 'اضافة فاتورة مبيعات', '8703', '2870', '2022-10-13 17:52:24', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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, 185, 165, 165
                    , 165, 165, 165, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+185, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063483422ce300 and sellbillId = 8703 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:22:24";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:52:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:52:24', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:24:47";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:54:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:54:47', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 063483438f3ca6
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:52:25', '063483438f3ca6', '1', '0.00', '0', '65', '1', '915', '850', '850', '0', '5', '2022-10-13 17:54:47', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','850','0','','0','0','850','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','8704', '0', '2022-10-13 17:54:47', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '850', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8108;
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 ('235','01091', '8704', '1', '1091', '1', '285', '285', '0', '', '1', '2022-10-13 17:54:47', '1091', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','8108-1,');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
                where sellbilldetailid = 25839;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1091, '2022-10-13', 264.754098361, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.754098361, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13', 264.754098361, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.754098361, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13 17:54:47' WHERE storedetailid = '3920';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1091', '5', '1', '1', '8704', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '7', '2022-10-13 17:54:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 9342;
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', '8704', '1', '474', '3', '210', '630', '0', '', '1', '2022-10-13 17:54:47', '474', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','9342-3,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 25840;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (474, '2022-10-13', 585.245901639, 510, 510
                    , 510, 510, 510, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+585.245901639, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, 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
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 585.245901639, 510, 510
                    , 510, 510, 510, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+585.245901639, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+510
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, 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;
UPDATE storedetail SET  productquantity = '52', userid = '7', storedetaildate = '2022-10-13 17:54:47' WHERE storedetailid = '1886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('474', '5', '3', '1', '8704', 'اضافة فاتورة مبيعات', 'sellbillController.php', '55.00', '52', '7', '2022-10-13 17:54:47','0','0');
UPDATE save SET  savecurrentvalue = '3720',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2870.00','850', '0', '5', 'اضافة فاتورة مبيعات', '8704', '3720', '2022-10-13 17:54:47', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 850, 745, 745
                    , 745, 745, 745, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , 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-10-13', 850, 745, 745
                    , 745, 745, 745, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 850, 745, 745
                    , 745, 745, 745, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+850, netSellCostBuyPrice = netSellCostBuyPrice+745
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+745
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+745
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+745
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+745
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 063483438f3ca6 and sellbillId = 8704 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:24:48";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:54:48", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:54:48', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:25:06";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:55:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:55:06', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:25:20";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:55:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:55:20', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634834db0a9c3
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:55:07', '0634834db0a9c3', '1', '0.00', '0', '5', '1', '205', '200', '-200', '0', '5', '2022-10-13 17:55:20', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-200','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','اضافة فاتورة مردوات مبيعات','3128', '0', '2022-10-13 17:55:20', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '200', '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 ('170.00', '00643', '3128', '1', '643', '1', '205', '205', '0', '', '1', '0', '643', '0.00', '0','5','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where returnsellbilldetailid = 6811;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (643, '2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 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+210, 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 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+210, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '7', storedetaildate = '2022-10-13 17:55:20' WHERE storedetailid = '2270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('643', '5', '1', '0', '3128', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '16.00', '17', '7', '2022-10-13 17:55:20','0','0');
UPDATE save SET  savecurrentvalue = '3520',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3720.00','200', '1', '5', 'اضافة فاتورة مردوات مبيعات', '3128', '3520', '2022-10-13 17:55:20', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , 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-10-13', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -200, -170, -170
                    , -170, -170, -170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-200, netSellCostBuyPrice = netSellCostBuyPrice+-170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634834db0a9c3 and sellbillId = 3128 and returnsellbillId = 3128
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:25:21";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:55:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:55:21', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:25:36";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:55:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:55:36', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:29:36";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:59:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:59:36', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634834f8b4e17
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:55:36', '0634834f8b4e17', '1', '0.00', '0', '0', '1', '1975', '1975', '1975', '0', '5', '2022-10-13 17:59:37', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '10' ,'0','','','','','-1','0','0','0','0','0','1975','0','','0','0','1975','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','اضافة فاتورة مبيعات','8705', '0', '2022-10-13 17:59:37', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1975', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8110;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01077', '8705', '1', '1077', '1', '235.00', '235', '0', '', '0', '2022-10-13 17:59:37', '1077', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','8110-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 292.50, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 292.50
                where sellbilldetailid = 25841;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1077, '2022-10-13', 235, 235, 350
                    , 292.5, 350, 292.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+292.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+292.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 235, 235, 350
                    , 292.5, 350, 292.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+292.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+292.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '3921';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1077', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2022-10-13 17:59:37','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 ('235','01018', '8705', '1', '1018', '1', '235', '235', '0', '', '0', '2022-10-13 17:59:37', '1018', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 235.00
                where sellbilldetailid = 25842;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1018, '2022-10-13', 235, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13', 235, 235, 235
                    , 235, 235, 235, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , 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-10-13 17:59:37' WHERE storedetailid = '3506';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1018', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 632;
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 ('125','00432', '8705', '1', '432', '1', '145', '145', '0', '', '0', '2022-10-13 17:59:37', '432', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','632-1,');
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
                where sellbilldetailid = 25843;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (432, '2022-10-13', 145, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , 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-10-13', 145, 125, 125
                    , 125, 125, 125, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , 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-10-13 17:59:37' WHERE storedetailid = '868';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('432', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '20', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 5158;
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','00854', '8705', '1', '854', '1', '195', '195', '0', '', '0', '2022-10-13 17:59:37', '854', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','5158-1,');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
                where sellbilldetailid = 25844;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (854, '2022-10-13', 195, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, 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 (5, '2022-10-13', 195, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, 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 = '10', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '3029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('854', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 9342;
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', '8705', '1', '474', '2', '170', '340', '0', '', '0', '2022-10-13 17:59:37', '474', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','9342-2,');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
                where sellbilldetailid = 25845;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (474, '2022-10-13', 340, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, 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-10-13', 340, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, 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 = '50', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '1886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('474', '5', '2', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52.00', '50', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 628;
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','00397', '8705', '1', '397', '1', '220', '220', '0', '', '0', '2022-10-13 17:59:37', '397', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','628-1,');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 207.50, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 207.50
                where sellbilldetailid = 25846;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (397, '2022-10-13', 220, 220, 195
                    , 207.5, 195, 207.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+207.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+207.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 220, 220, 195
                    , 207.5, 195, 207.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+207.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+207.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '57', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '866';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('397', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '58.00', '57', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 3360;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('185','00574', '8705', '1', '574', '1', '220', '220', '0', '', '0', '2022-10-13 17:59:37', '574', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','3360-1,');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 202.50, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 202.50
                where sellbilldetailid = 25847;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (574, '2022-10-13', 220, 220, 185
                    , 202.5, 185, 202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 220, 220, 185
                    , 202.5, 185, 202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '2261';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('574', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12.00', '11', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 5414;
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','00935', '8705', '1', '935', '1', '180', '180', '0', '', '0', '2022-10-13 17:59:37', '935', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','5414-1,');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
                where sellbilldetailid = 25848;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (935, '2022-10-13', 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 (5, '2022-10-13', 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 = '0', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '3142';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('935', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1.00', '0', '7', '2022-10-13 17:59:37','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 626;
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','00393', '8705', '1', '393', '1', '205', '205', '0', '', '0', '2022-10-13 17:59:37', '393', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','626-1,');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
                where sellbilldetailid = 25849;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (393, '2022-10-13', 205, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, 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 (5, '2022-10-13', 205, 195, 195
                    , 195, 195, 195, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, 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 = '15', userid = '7', storedetaildate = '2022-10-13 17:59:37' WHERE storedetailid = '865';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('393', '5', '1', '1', '8705', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2022-10-13 17:59:37','0','0');
UPDATE save SET  savecurrentvalue = '5495',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3520.00','1975', '0', '5', 'اضافة فاتورة مبيعات', '8705', '5495', '2022-10-13 17:59:37', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 1975, 1945, 2000
                    , 1972.5, 2000, 1972.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1975, sellCostBuyPrice =sellCostBuyPrice+1945
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1972.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1972.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 1975, 1945, 2000
                    , 1972.5, 2000, 1972.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1975, sellCostBuyPrice =sellCostBuyPrice+1945
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1972.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1972.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1975, 1945, 2000
                    , 1972.5, 2000, 1972.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1975, netSellCostBuyPrice = netSellCostBuyPrice+1945
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1972.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1972.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634834f8b4e17 and sellbillId = 8705 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:29:37";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:59:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:59:37', '7', 'addsellBill', '197.192.205.152', '', '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-10-13 14:29:45";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 17:59:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 17:59:46', '5', '', '197.55.173.253', '', '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-10-13 14:29:46";
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-10-13 14:29:48";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 17:59:48", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 17:59:48', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:29:58";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 17:59:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 17:59:58', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:30:13";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:00:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 18:00:13', '7', 'add', '197.192.205.152', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'عمادحمدي', '', '40', '2022-10-13', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5455',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5495.00','40', '1', '5', 'إضافة مصروف', '1910', '5455', '2022-10-13 18:00:14', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '40', '40', '2022-10-13', '7', '0', '0', '2022-10-13 18:00:14','اضافة اسم مصروف( عمادحمدي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4933', '145', '40', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '264195', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4933', '139', '40', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1145729', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'عمادحمدي', expensesdetails = '', expensesValue = '40.00', expensesdate = '2022-10-13', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '4933', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1910';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:30:14";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:00:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 18:00:14', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:30:23";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:00:23", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 18:00:23', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:30:41";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:00:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 18:00:41', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:01";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 18:01:02', '7', 'add', '197.192.205.152', '', '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', '-1168901.00', '2000', '1', 'ايصال دفع لمورد', '267', '-1170901', '2022-10-13 18:00:41', '7', 'supplierPayedDeptController.php', 'جمعيه اودي', '0','5', '-1','1','1','1','1');
UPDATE supplier SET  suppliercurrentDebt = '-1170901', userid = '7', supplierdate = '2022-10-13 18:01:02'   WHERE supplierid = '1';
UPDATE save SET  savecurrentvalue = '3455',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5455.00','2000', '1', '5', 'ايصال دفع لمورد', '642', '3455', '2022-10-13 18:01:02', '7',  'supplierPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '2000', '2000', '2022-10-13', '7', '0', '0', '2022-10-13 18:01:02','ايصال دفع لمورد ( مباشر ) ','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4934', '168', '2000', '','0');
UPDATE accountstree SET name = 'مباشر', customName = 'مباشر', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '7', mydate = '2021-12-11', itemtype2 = '1', theValue = '-1170901', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '168';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4934', '139', '2000', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1147729', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE supplierdebtchange SET supplierid = '1', supplierdebtchangebefore = '-1168901.00', supplierdebtchangeamount = '2000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '267', supplierdebtchangeafter = '-1170901.00', supplierdebtchangedate = '2022-10-13 18:00:41', userid = '7', tablename = 'supplierPayedDeptController.php', comment = 'جمعيه اودي', dailyentryid = '4934',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE supplierdebtchangeid = '642';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:02";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 18:01:02', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:04";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 18:01:04', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:04";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2022-10-13 18:01:05', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:07";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:07", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:01:07', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:31:09";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:01:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:01:09', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:33:32";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:03:32", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:03:32', '5', 'addAndRetuen', '197.55.173.253', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634835f44a07e
-- ----------------------------------------------------------------------------------------------------

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-10-13 17:59:48', '0634835f44a07e', '1', '0.00', '0', '0', '1', '2665', '2665', '2665', '0', '3', '2022-10-13 18:03:33', '', '5', '0', 'نقدي', '3', '0', '3', '0', 'نقدي', '12' ,'0','','','','','-1','0','0','0','0','0','2665','0','','0','0','2665','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','اضافة فاتورة مبيعات','8706', '0', '2022-10-13 18:03:33', '5', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2665', '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 ('220','00658', '8706', '1', '658', '3', '240', '720', '0', '', '2', '2022-10-13 18:03:33', '658', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 217.50, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 217.50
                where sellbilldetailid = 25850;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (658, '2022-10-13', 720, 660, 645
                    , 652.5, 645, 652.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+652.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+652.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , 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-10-13', 720, 660, 645
                    , 652.5, 645, 652.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+652.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+652.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '151', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '2208';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('658', '3', '3', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '154.00', '151', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 1666;
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','00223', '8706', '1', '223', '2', '175', '350', '0', '', '2', '2022-10-13 18:03:33', '223', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','1666-2,');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 25851;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (223, '2022-10-13', 350, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+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-10-13', 350, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '1384';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('223', '3', '2', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '11', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9376;
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', '8706', '1', '123', '1', '190', '190', '0', '', '2', '2022-10-13 18:03:33', '123', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','9376-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 25852;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (123, '2022-10-13', 190, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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-10-13', 190, 200, 200
                    , 200, 200, 200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '2', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '2015';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('123', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 4132;
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 ('190','00801', '8706', '1', '801', '1', '200', '200', '0', '', '2', '2022-10-13 18:03:33', '801', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','4132-1,');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
                where sellbilldetailid = 25853;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (801, '2022-10-13', 200, 190, 190
                    , 190, 190, 190, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , 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-10-13', 200, 190, 190
                    , 190, 190, 190, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '2581';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('801', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8090;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01077', '8706', '1', '1077', '1', '245', '245', '0', '', '2', '2022-10-13 18:03:33', '1077', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','8090-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 292.50, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 292.50
                where sellbilldetailid = 25854;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1077, '2022-10-13', 245, 235, 350
                    , 292.5, 350, 292.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+292.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+292.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (3, '2022-10-13', 245, 235, 350
                    , 292.5, 350, 292.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+292.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+292.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '3912';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1077', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7056;
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 ('290','01021', '8706', '1', '1021', '1', '255', '255', '0', '', '2', '2022-10-13 18:03:33', '1021', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','7056-1,');
UPDATE sellbilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 263.75, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 263.75
                where sellbilldetailid = 25855;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1021, '2022-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , 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-10-13', 255, 245, 290
                    , 263.75, 290, 263.75, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+263.75
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+263.75
                            , 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 = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '3561';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1021', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22.00', '21', '5', '2022-10-13 18:03:33','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 ('230','01050', '8706', '1', '1050', '1', '240', '240', '0', '', '2', '2022-10-13 18:03:33', '1050', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
                where sellbilldetailid = 25856;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1050, '2022-10-13', 240, 230, 230
                    , 230, 230, 230, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, 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 (3, '2022-10-13', 240, 230, 230
                    , 230, 230, 230, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, 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 = '0', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '3665';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1050', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1.00', '0', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 1696;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('185','00021', '8706', '1', '21', '1', '190', '190', '0', '', '2', '2022-10-13 18:03:33', '21', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','1696-1,');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 182.50, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 182.50
                where sellbilldetailid = 25857;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (21, '2022-10-13', 190, 180, 185
                    , 182.5, 185, 182.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+182.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+182.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (3, '2022-10-13', 190, 180, 185
                    , 182.5, 185, 182.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+182.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+182.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '1399';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('21', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '19', '5', '2022-10-13 18:03:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7598;
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','01060', '8706', '1', '1060', '1', '275', '275', '0', '', '2', '2022-10-13 18:03:33', '1060', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','7598-1,');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
                where sellbilldetailid = 25858;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1060, '2022-10-13', 275, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, 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 (3, '2022-10-13', 275, 265, 265
                    , 265, 265, 265, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, 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 = '17', userid = '5', storedetaildate = '2022-10-13 18:03:33' WHERE storedetailid = '3714';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1060', '3', '1', '1', '8706', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '5', '2022-10-13 18:03:33','0','0');
UPDATE save SET  savecurrentvalue = '7400',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4735.00','2665', '0', '3', 'اضافة فاتورة مبيعات', '8706', '7400', '2022-10-13 18:03:33', '5',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 2665, 2525, 2675
                    , 2596.25, 2675, 2596.25, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2665, sellCostBuyPrice =sellCostBuyPrice+2525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2596.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2596.25
                            , 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-10-13', 2665, 2525, 2675
                    , 2596.25, 2675, 2596.25, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2665, sellCostBuyPrice =sellCostBuyPrice+2525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2675, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2596.25
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2675, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2596.25
                            , 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, 2665, 2525, 2675
                    , 2596.25, 2675, 2596.25, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2665, netSellCostBuyPrice = netSellCostBuyPrice+2525
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2675
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2596.25
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2675
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2596.25
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634835f44a07e and sellbillId = 8706 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:33:33";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:03:33", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:03:33', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:33:37";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:03:37", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:03:37', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:33:41";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:03:41", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:03:41', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:33:57";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:03:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:03:57', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:34:09";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 18:04:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:04:09', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:04";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:05", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:06:05', '5', 'addAndRetuen', '197.55.173.253', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634836ddd4fe3
-- ----------------------------------------------------------------------------------------------------

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-10-13 18:03:41', '0634836ddd4fe3', '1', '0.00', '0', '0', '1', '615', '615', '615', '0', '3', '2022-10-13 18:06:05', '', '5', '0', 'نقدي', '3', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','615','0','','0','0','615','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','اضافة فاتورة مبيعات','8707', '0', '2022-10-13 18:06:05', '5', 'sellbillController.php', 'اضافة فاتورة مبيعات', '615', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8342;
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','01111', '8707', '1', '1111', '1', '220.00', '220', '0', '', '2', '2022-10-13 18:06:05', '1111', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','8342-1,');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where sellbilldetailid = 25859;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1111, '2022-10-13', 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 (3, '2022-10-13', 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 = '27', userid = '5', storedetaildate = '2022-10-13 18:06:05' WHERE storedetailid = '3982';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1111', '3', '1', '1', '8707', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28.00', '27', '5', '2022-10-13 18:06:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 1734;
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 ('165','00163', '8707', '1', '163', '1', '185.00', '185', '0', '', '2', '2022-10-13 18:06:05', '163', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','1734-1,');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
                where sellbilldetailid = 25860;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (163, '2022-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-10-13', 185, 165, 165
                    , 165, 165, 165, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '5', storedetaildate = '2022-10-13 18:06:05' WHERE storedetailid = '1418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('163', '3', '1', '1', '8707', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '5', '2022-10-13 18:06:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 8092;
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','01090', '8707', '1', '1090', '1', '210.00', '210', '0', '', '2', '2022-10-13 18:06:05', '1090', '0.00', '0', '3','0','','','0','0','0','0','0','0','2','0','','8092-1,');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
                where sellbilldetailid = 25861;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1090, '2022-10-13', 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-10-13', 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 = '5', userid = '5', storedetaildate = '2022-10-13 18:06:05' WHERE storedetailid = '3913';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1090', '3', '1', '1', '8707', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '5', '2022-10-13 18:06:05','0','0');
UPDATE save SET  savecurrentvalue = '8015',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7400.00','615', '0', '3', 'اضافة فاتورة مبيعات', '8707', '8015', '2022-10-13 18:06:05', '5',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 615, 575, 575
                    , 575, 575, 575, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+615, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , 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-10-13', 615, 575, 575
                    , 575, 575, 575, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+615, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , 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, 615, 575, 575
                    , 575, 575, 575, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+615, netSellCostBuyPrice = netSellCostBuyPrice+575
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+575
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+575
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+575
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+575
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634836ddd4fe3 and sellbillId = 8707 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:05";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:05", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:06:05', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:09";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:09", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:06:09', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:16";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:16", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:06:16', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:21";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:21", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:06:21', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:36:24";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:06:24", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:06:24', '5', 'showDetail', '197.55.173.253', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:55:22";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:25:22", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 18:25:22', '5', '', '197.55.173.253', '', '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-10-13 14:55:23";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 14:55:28";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:25:28", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-10-13 18:25:28', '5', '', '197.55.173.253', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:08:49";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:38:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 18:38:49', '5', '', '197.55.173.253', '', '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-10-13 15:08:49";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:08:51";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:38:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:38:51', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:09:14";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:39:14", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-10-13 18:39:14', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:09:29";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:39:29", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-10-13 18:39:29', '5', 'add', '197.55.173.253', '', '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 =13142
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(69,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '32300' , clientdate = '2022-10-13 18:39:29', userid = '5' WHERE clientid = '69';
UPDATE client SET  inUse = 0 where clientid = 69;
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 ('69','34300.00','2000','1','ايصال تحصيل (( قبض من عميل ))','13142', '32300', '2022-10-13 18:39:14', '5', 'clientPayedDeptController.php', '   ', '2000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '10015',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8015.00','2000', '0', '3', 'ايصال تحصيل (( قبض من عميل ))', '13142', '10015', '2022-10-13 18:39:29', '5',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '2000', '2000', '2022-10-13', '5', '0', '0', '2022-10-13 18:39:29','اضافة ايصال سداد للعميل سنتر مكه','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4935', '137', '2000', '','0');
UPDATE accountstree SET name = 'خزينة رائد', customName = 'خزينة رائد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-696555', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4935', '122', '2000', '','0');
UPDATE accountstree SET name = 'سنتر مكه', customName = 'سنتر مكه', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-76910', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '122';
UPDATE clientdebtchange SET clientid = '69', clientdebtchangebefore = '34300.00', clientdebtchangeamount = '2000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '13142', clientdebtchangeafter = '32300.00', clientdebtchangedate = '2022-10-13 18:39:14', userid = '5', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2000.00',discount='', reciptid=null, dailyentryid = '4935',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '13142';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:09:29";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:39:29", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-10-13 18:39:29', '5', 'sucess', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:09:31";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:39:31", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2022-10-13 18:39:31', '5', 'show', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:09:32";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:39:32", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 18:39:32', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:15:47";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 18:45:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 18:45:47', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:16:43";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 18:46:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 18:46:43', '1', 'add', '156.210.29.230', '', '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 ('704اسيا شتوي','','1','250','270', '300','290', '2022-10-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '250','250','250','250','250','0','8','16','20','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '704اسيا شتوي', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '270', productSellUnitPrice = '300', productSellHalfPrice = '290', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01141',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250' , buypricereal_precentage = '0' , buytotal_precentage = '8' , buyhalf_precentage = '16' , buypart_precentage = '20',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1141';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1141', '1', '2022-10-13', '1', '0','0114101','270','290','300','250');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1141', '1', '36', '1', '2022-10-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '1', '36', '0', '1141', 'إضافة منتج', 'productController.php', '0', '36', '1', '2022-10-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1141, 1,'2022-10-13 18:46:43',1)
                ON DUPLICATE KEY UPDATE productid = 1141, edited = 1, sysdate = '2022-10-13 18:46:43', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '9000', '9000', '2022-10-13', '1', '0', '0', '2022-10-13 18:46:43','إضافة منتج 704اسيا شتوي الكمية 36','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4936', '19', '9000', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10461855.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4936', '7', '9000', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11230301.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '704اسيا شتوي', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '270.00', productSellUnitPrice = '300.00', productSellHalfPrice = '290.00', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01141',type ='0', expireDate = '0' , dailyentryId = '4936',isService = '0',isOptic = '0',lastbuyprice = '250',lastbuyprice_withDiscount = '250',meanbuyprice = '250',meanbuyprice_withDiscount = '250' , productbuypricereal = '250' , buypricereal_precentage = '0' , buytotal_precentage = '8' , buyhalf_precentage = '16' , buypart_precentage = '20',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1141';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:16:45";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 18:46:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 18:46:45', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:16:47";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 18:46:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:46:47', '1', 'addsellBill', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:16:58";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 18:46:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:46:58', '1', 'addsellBill', '156.210.29.230', '', '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-10-13 15:23:46";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:53:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 18:53:46', '5', '', '197.55.173.253', '', '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-10-13 15:23:46";
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-10-13 15:23:49";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 18:53:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 18:53:49', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:46:35";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 19:16:35", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 19:16:35', '5', '', '197.55.173.253', '', '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-10-13 15:46: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

;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 15:48:31";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 19:18:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 19:18:31', '7', '', '197.55.173.253', '', '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-10-13 15:48:32";
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-10-13 15:48:34";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 19:18:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 19:18:35', '7', 'addsellBill', '197.55.173.253', '', '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-10-13 16:34:12";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 20:04:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 20:04:12', '7', '', '197.55.173.253', '', '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-10-13 16:34:12";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 16:34:15";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 20:04:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 20:04:15', '7', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 16:55:28";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 20:25:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 20:25:28', '7', 'addAndRetuen', '197.192.205.152', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0634836f9cfc18
-- ----------------------------------------------------------------------------------------------------

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-10-13 18:04:09', '0634836f9cfc18', '1', '0.00', '0', '0', '1', '555', '555', '555', '0', '5', '2022-10-13 20:25:28', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','555','0','','0','0','555','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','اضافة فاتورة مبيعات','8708', '0', '2022-10-13 20:25:28', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '555', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 9000;
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','00013', '8708', '1', '13', '1', '195', '195', '0', '', '2', '2022-10-13 20:25:28', '13', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','9000-1,');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
                where sellbilldetailid = 25862;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (13, '2022-10-13', 195, 175, 175
                    , 175, 175, 175, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+175
                            , 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-10-13', 195, 175, 175
                    , 175, 175, 175, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+195, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+175
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+175
                            , 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-10-13 20:25:28' WHERE storedetailid = '4088';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13', '5', '1', '1', '8708', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '7', '2022-10-13 20:25:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 7546;
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 ('165','00159', '8708', '1', '159', '1', '190', '190', '0', '', '2', '2022-10-13 20:25:28', '159', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','7546-1,');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 172.50, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 172.50
                where sellbilldetailid = 25863;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (159, '2022-10-13', 190, 180, 165
                    , 172.5, 165, 172.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2022-10-13', 190, 180, 165
                    , 172.5, 165, 172.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '7', storedetaildate = '2022-10-13 20:25:28' WHERE storedetailid = '812';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('159', '5', '1', '1', '8708', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2022-10-13 20:25:28','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 ('160','00936', '8708', '1', '936', '1', '170', '170', '0', '', '2', '2022-10-13 20:25:28', '936', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
                where sellbilldetailid = 25864;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (936, '2022-10-13', 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-10-13', 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 = '3', userid = '7', storedetaildate = '2022-10-13 20:25:28' WHERE storedetailid = '3143';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('936', '5', '1', '1', '8708', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4.00', '3', '7', '2022-10-13 20:25:28','0','0');
UPDATE save SET  savecurrentvalue = '4010',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3455.00','555', '0', '5', 'اضافة فاتورة مبيعات', '8708', '4010', '2022-10-13 20:25:28', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2022-10-13', 555, 515, 500
                    , 507.5, 500, 507.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+507.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+507.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2022-10-13', 555, 515, 500
                    , 507.5, 500, 507.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+507.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+507.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 555, 515, 500
                    , 507.5, 500, 507.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+555, netSellCostBuyPrice = netSellCostBuyPrice+515
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+507.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+507.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0634836f9cfc18 and sellbillId = 8708 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 16:55:29";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 20:25:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 20:25:29', '7', 'addsellBill', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:00:57";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:30:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 20:30:57', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:04:13";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:34:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 20:34:13', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:04:47";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:34:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 20:34:47', '1', 'show', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:04:57";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:34:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 20:34:57', '1', 'show', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:05:09";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:35:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 20:35:09', '1', 'show', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:08:43";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:38:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 20:38:43', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:13:08";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:43:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 20:43:08', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:14:01";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:44:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 20:44:01', '1', 'addsellBill', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:15:23";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:45:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 20:45:23', '1', 'add', '156.210.29.230', '', '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 ('تشكيل شتوي ','','1','200','215', '250','230', '2022-10-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '200','200','200','200','200','0','7.5','15','25','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'تشكيل شتوي ', productDescription = '', productCatId = '1', productBuyPrice = '200', productSellAllPrice = '215', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01142',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 = '7.5' , buyhalf_precentage = '15' , buypart_precentage = '25',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1142';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1142', '1', '2022-10-13', '1', '0','0114201','215','230','250','200');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1142', '1', '150', '1', '2022-10-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '1', '150', '0', '1142', 'إضافة منتج', 'productController.php', '0', '150', '1', '2022-10-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1142, 1,'2022-10-13 20:45:23',1)
                ON DUPLICATE KEY UPDATE productid = 1142, edited = 1, sysdate = '2022-10-13 20:45:23', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '30000', '30000', '2022-10-13', '1', '0', '0', '2022-10-13 20:45:23','إضافة منتج تشكيل شتوي  الكمية 150','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4937', '19', '30000', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10491855.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4937', '7', '30000', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11260301.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'تشكيل شتوي ', productDescription = '', productCatId = '1', productBuyPrice = '200.00', productSellAllPrice = '215.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01142',type ='0', expireDate = '0' , dailyentryId = '4937',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '7.5' , buyhalf_precentage = '15' , buypart_precentage = '25',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1142';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:15:24";
UPDATE user SET loginip = "156.210.29.230", lastactivetime = "2022-10-13 20:45:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 20:45:25', '1', '', '156.210.29.230', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:35:25";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:05:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:05:25', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:35:42";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:05:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:05:42', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '150.00', productSellUnitPrice = '180.00', productSellHalfPrice = '160.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:06:08',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:06:08', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:06:12',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:06:12', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:06:18',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:06:18', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '210', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:06:33',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:06:33', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '175.00', productSellUnitPrice = '210.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '260.63',meanbuyprice_withDiscount = '260.63' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:07',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:07', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '260.63',meanbuyprice_withDiscount = '260.63' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:07',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:07', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '390', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '260.63',meanbuyprice_withDiscount = '260.63' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:08',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:08', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '420', productSellHalfPrice = '390.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '260.63',meanbuyprice_withDiscount = '260.63' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:08',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:08', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '350.00', productSellUnitPrice = '420.00', productSellHalfPrice = '390.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '217.82',meanbuyprice_withDiscount = '217.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:16',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:16', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '217.82',meanbuyprice_withDiscount = '217.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '217.82',meanbuyprice_withDiscount = '217.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:27',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:27', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '210', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '217.82',meanbuyprice_withDiscount = '217.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:07:31',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:07:31', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '175.00', productSellUnitPrice = '210.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '283.91',meanbuyprice_withDiscount = '283.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:10',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:10', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '175.00', productSellUnitPrice = '420', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '283.91',meanbuyprice_withDiscount = '283.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:10',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:10', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '283.91',meanbuyprice_withDiscount = '283.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:11',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:11', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '390', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '283.91',meanbuyprice_withDiscount = '283.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:11',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:11', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '390.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '229.46',meanbuyprice_withDiscount = '229.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '229.46',meanbuyprice_withDiscount = '229.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:32',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:32', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '229.46',meanbuyprice_withDiscount = '229.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:38',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:38', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '210', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '229.46',meanbuyprice_withDiscount = '229.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:46',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:46', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '175.00', productSellUnitPrice = '210.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '289.73',meanbuyprice_withDiscount = '289.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:50',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:50', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '175.00', productSellUnitPrice = '420', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '289.73',meanbuyprice_withDiscount = '289.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:51',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:51', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '289.73',meanbuyprice_withDiscount = '289.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:51',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:51', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '390', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '289.73',meanbuyprice_withDiscount = '289.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:08:51',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:08:51', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:38:54";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:08:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:08:54', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:39:29";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:09:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:09:29', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:39:33";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:09:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 21:09:33', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:40:47";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:10:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:10:47', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:41:27";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:11:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:11:27', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '390.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '232.37',meanbuyprice_withDiscount = '232.37' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:11:39',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:11:39', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '232.37',meanbuyprice_withDiscount = '232.37' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:11:46',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:11:46', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '232.37',meanbuyprice_withDiscount = '232.37' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:11:50',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:11:50', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '210', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '232.37',meanbuyprice_withDiscount = '232.37' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:11:55',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:11:55', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '175.00', productSellUnitPrice = '210.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '291.19',meanbuyprice_withDiscount = '291.19' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:19',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:19', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '175.00', productSellUnitPrice = '210.00', productSellHalfPrice = '370', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '291.19',meanbuyprice_withDiscount = '291.19' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:19',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:19', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '175.00', productSellUnitPrice = '385', productSellHalfPrice = '370.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '291.19',meanbuyprice_withDiscount = '291.19' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:19',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:19', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '291.19',meanbuyprice_withDiscount = '291.19' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:19',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:19', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '350.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.1',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:20',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:20', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525.00', productSellAllPrice = '525', productSellUnitPrice = '525', productSellHalfPrice = '525', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.10',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:20',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:20', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525.00', productSellAllPrice = '525.00', productSellUnitPrice = '525.00', productSellHalfPrice = '545', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.10',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:20',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:20', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525.00', productSellAllPrice = '525.00', productSellUnitPrice = '560', productSellHalfPrice = '545.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.10',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:20',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:20', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525.00', productSellAllPrice = '700', productSellUnitPrice = '700', productSellHalfPrice = '700', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.10',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '525.00', productSellAllPrice = '700.00', productSellUnitPrice = '735', productSellHalfPrice = '700.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '408.10',meanbuyprice_withDiscount = '408.1' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '700', productSellAllPrice = '700.00', productSellUnitPrice = '735.00', productSellHalfPrice = '700.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '554.05',meanbuyprice_withDiscount = '554.05' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '700.00', productSellAllPrice = '700.00', productSellUnitPrice = '735.00', productSellHalfPrice = '720', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '554.05',meanbuyprice_withDiscount = '554.05' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '700.00', productSellAllPrice = '700.00', productSellUnitPrice = '910', productSellHalfPrice = '720.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '554.05',meanbuyprice_withDiscount = '554.05' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:21',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:21', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '700.00', productSellAllPrice = '700.00', productSellUnitPrice = '910.00', productSellHalfPrice = '895', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '554.05',meanbuyprice_withDiscount = '554.05' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:22',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:22', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '875', productSellAllPrice = '700.00', productSellUnitPrice = '910.00', productSellHalfPrice = '895.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '714.53',meanbuyprice_withDiscount = '714.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:22',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:22', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '875.00', productSellAllPrice = '875', productSellUnitPrice = '875', productSellHalfPrice = '875', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '714.53',meanbuyprice_withDiscount = '714.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:22',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:22', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1050', productSellAllPrice = '875.00', productSellUnitPrice = '875.00', productSellHalfPrice = '875.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '882.27',meanbuyprice_withDiscount = '882.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:22',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:22', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1050.00', productSellAllPrice = '875.00', productSellUnitPrice = '1085', productSellHalfPrice = '875.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '882.27',meanbuyprice_withDiscount = '882.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:23',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1225', productSellAllPrice = '875.00', productSellUnitPrice = '1085.00', productSellHalfPrice = '875.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1053.64',meanbuyprice_withDiscount = '1053.64' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:23',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1225.00', productSellAllPrice = '875.00', productSellUnitPrice = '1085.00', productSellHalfPrice = '1245', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1053.64',meanbuyprice_withDiscount = '1053.64' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:23',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1225.00', productSellAllPrice = '875.00', productSellUnitPrice = '1085.00', productSellHalfPrice = '1070', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1053.64',meanbuyprice_withDiscount = '1053.64' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:23',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1225.00', productSellAllPrice = '1225', productSellUnitPrice = '1225', productSellHalfPrice = '1225', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1053.64',meanbuyprice_withDiscount = '1053.64' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:23',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1225.00', productSellAllPrice = '1050', productSellUnitPrice = '1050', productSellHalfPrice = '1050', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1053.64',meanbuyprice_withDiscount = '1053.64' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1400', productSellAllPrice = '1050.00', productSellUnitPrice = '1050.00', productSellHalfPrice = '1050.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1226.82',meanbuyprice_withDiscount = '1226.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1400.00', productSellAllPrice = '1400', productSellUnitPrice = '1400', productSellHalfPrice = '1400', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1226.82',meanbuyprice_withDiscount = '1226.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1400.00', productSellAllPrice = '1400.00', productSellUnitPrice = '1400.00', productSellHalfPrice = '1420', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1226.82',meanbuyprice_withDiscount = '1226.82' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1575', productSellAllPrice = '1400.00', productSellUnitPrice = '1400.00', productSellHalfPrice = '1420.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1400.91',meanbuyprice_withDiscount = '1400.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1575.00', productSellAllPrice = '1400.00', productSellUnitPrice = '1260', productSellHalfPrice = '1420.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1400.91',meanbuyprice_withDiscount = '1400.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:24',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:24', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1575.00', productSellAllPrice = '1400.00', productSellUnitPrice = '1435', productSellHalfPrice = '1420.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1400.91',meanbuyprice_withDiscount = '1400.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:25',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:25', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1575.00', productSellAllPrice = '1400.00', productSellUnitPrice = '1610', productSellHalfPrice = '1420.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1400.91',meanbuyprice_withDiscount = '1400.91' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:25',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:25', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750', productSellAllPrice = '1400.00', productSellUnitPrice = '1610.00', productSellHalfPrice = '1420.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:25',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:25', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750.00', productSellAllPrice = '1575', productSellUnitPrice = '1575', productSellHalfPrice = '1575', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:25',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:25', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750.00', productSellAllPrice = '1750', productSellUnitPrice = '1750', productSellHalfPrice = '1750', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:26',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:26', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1750.00', productSellHalfPrice = '1770', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:26',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:26', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1785', productSellHalfPrice = '1770.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:26',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:26', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1750.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1785.00', productSellHalfPrice = '1595', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1575.46',meanbuyprice_withDiscount = '1575.46' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:26',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:26', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760', productSellAllPrice = '1750.00', productSellUnitPrice = '1785.00', productSellHalfPrice = '1595.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:27',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:27', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1795.2', productSellHalfPrice = '1595.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1795.20', productSellHalfPrice = '1780.1142857142856', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1795.20', productSellHalfPrice = '1790.2863673469387', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760.00', productSellAllPrice = '1750.00', productSellUnitPrice = '1805.4582857142857', productSellHalfPrice = '1790.29', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1760.00', productSellAllPrice = '1770.057142857143', productSellUnitPrice = '1770.057142857143', productSellHalfPrice = '1770.057142857143', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1667.73',meanbuyprice_withDiscount = '1667.73' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:28',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:28', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1770.057142857143', productSellAllPrice = '1770.06', productSellUnitPrice = '1770.06', productSellHalfPrice = '1770.06', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1718.89',meanbuyprice_withDiscount = '1718.89' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1780.1717551020408', productSellAllPrice = '1770.06', productSellUnitPrice = '1770.06', productSellHalfPrice = '1770.06', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1749.53',meanbuyprice_withDiscount = '1749.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1780.17', productSellAllPrice = '1780.1717551020408', productSellUnitPrice = '1780.1717551020408', productSellHalfPrice = '1780.1717551020408', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1749.53',meanbuyprice_withDiscount = '1749.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1780.17', productSellAllPrice = '1780.17', productSellUnitPrice = '1780.17', productSellHalfPrice = '1800.5165751603497', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1749.53',meanbuyprice_withDiscount = '1749.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1780.17', productSellAllPrice = '1780.17', productSellUnitPrice = '1815.7751902040816', productSellHalfPrice = '1800.52', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1749.53',meanbuyprice_withDiscount = '1749.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '1780.17', productSellAllPrice = '1760', productSellUnitPrice = '1760', productSellHalfPrice = '1760', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '1749.53',meanbuyprice_withDiscount = '1749.53' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:29',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '1760.00', productSellUnitPrice = '1760.00', productSellHalfPrice = '1760.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '962.27',meanbuyprice_withDiscount = '962.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:35',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:35', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '962.27',meanbuyprice_withDiscount = '962.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:38',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:38', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '962.27',meanbuyprice_withDiscount = '962.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:43',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:43', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '210', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '962.27',meanbuyprice_withDiscount = '962.27' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 21:12:46',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 21:12:46', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:43:09";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:13:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:13:09', '1', 'showNew', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:43:10";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:13:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 21:13:11', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:46:44";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:16:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:16:44', '1', 'add', '156.210.21.236', '', '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(1097,1,5,466,24,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 21:16:44',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '130', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '466';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 1, 466, 0, 0
                    , 240.00, 24, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-24, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2022-02-27*240.00," WHERE transferproductid = 4683;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('466', '1', '24', '1', '4683', 'تحويل منتجات من المخزن', 'storemovementController.php', '154.00', '130', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('466', '5', '24', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 5, 466, 0, 0
                    , 240.00, 24, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('466', '5', '24', '0', '4683', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2022-10-13','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', '518', '21', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '104', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '518';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 518, 0, 0
                    , 210.00, 21, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-21, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2022-02-28*210.00," WHERE transferproductid = 4684;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '21', '1', '4684', 'تحويل منتجات من المخزن', 'storemovementController.php', '125.00', '104', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '909';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 518, 0, 0
                    , 210.00, 21, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '5', '21', '0', '4684', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '21', '1', '2022-10-13','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', '515', '20', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '43', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '515';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 515, 0, 0
                    , 220.00, 20, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-20, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2022-02-28*220.00," WHERE transferproductid = 4685;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '1', '20', '1', '4685', 'تحويل منتجات من المخزن', 'storemovementController.php', '63.00', '43', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '906';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 515, 0, 0
                    , 220.00, 20, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '5', '20', '0', '4685', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '20', '1', '2022-10-13','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', '1142', '20', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '130', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4164';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1142, 0, 0
                    , 200.00, -20, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2022-10-13*200.00," WHERE transferproductid = 4686;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '1', '20', '1', '4686', 'تحويل منتجات من المخزن', 'storemovementController.php', '150.00', '130', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1142', '5', '20', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1142, 0, 0
                    , 200.00, 20, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '5', '20', '0', '4686', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2022-10-13','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', '513', '31', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '51', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '513';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 1, 513, 0, 0
                    , 210.00, 2, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 513, 0, 0
                    , 210.00, 29, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-29, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2022-02-27*210.00,29*2022-02-28*210.00," WHERE transferproductid = 4687;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '1', '31', '1', '4687', 'تحويل منتجات من المخزن', 'storemovementController.php', '82.00', '51', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '904';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 5, 513, 0, 0
                    , 210.00, 2, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 513, 0, 0
                    , 210.00, 29, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+29, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '5', '31', '0', '4687', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '31', '1', '2022-10-13','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', '514', '23', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '73', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '514';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 514, 0, 0
                    , 210.00, 23, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-23, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2022-02-28*210.00," WHERE transferproductid = 4688;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '1', '23', '1', '4688', 'تحويل منتجات من المخزن', 'storemovementController.php', '96.00', '73', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '905';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 514, 0, 0
                    , 210.00, 23, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '5', '23', '0', '4688', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '24', '1', '2022-10-13','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', '560', '16', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1479';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 560, 0, 0
                    , 220.00, 16, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-16, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2022-02-28*220.00," WHERE transferproductid = 4689;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '16', '1', '4689', 'تحويل منتجات من المخزن', 'storemovementController.php', '44.00', '28', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1549';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 560, 0, 0
                    , 220.00, 16, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '5', '16', '0', '4689', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '5.00', '21', '1', '2022-10-13','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', '561', '16', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '93', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1480';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 561, 0, 0
                    , 210.00, 16, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-16, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2022-02-28*210.00," WHERE transferproductid = 4690;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '16', '1', '4690', 'تحويل منتجات من المخزن', 'storemovementController.php', '109.00', '93', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1495';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 561, 0, 0
                    , 210.00, 16, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '5', '16', '0', '4690', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '4.00', '20', '1', '2022-10-13','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', '516', '15', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '516';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 516, 0, 0
                    , 220.00, 10, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 516, 0, 0
                    , 220.00, -5, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2022-02-28*220.00,5*2022-10-13*220.00," WHERE transferproductid = 4691;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('516', '1', '15', '1', '4691', 'تحويل منتجات من المخزن', 'storemovementController.php', '42.00', '27', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '907';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 516, 0, 0
                    , 220.00, 10, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 516, 0, 0
                    , 220.00, 5, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('516', '5', '15', '0', '4691', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '15', '1', '2022-10-13','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', '124', '8', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '144', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '124';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 124, 0, 0
                    , 185.00, 8, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2022-02-28*185.00," WHERE transferproductid = 4692;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '8', '1', '4692', 'تحويل منتجات من المخزن', 'storemovementController.php', '152.00', '144', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '915';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 124, 0, 0
                    , 185.00, 8, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '5', '8', '0', '4692', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '-1.00', '7', '1', '2022-10-13','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', '125', '29', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '130', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '125';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 125, 0, 0
                    , 185.00, 29, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-29, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "29*2022-02-28*185.00," WHERE transferproductid = 4693;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '1', '29', '1', '4693', 'تحويل منتجات من المخزن', 'storemovementController.php', '159.00', '130', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '914';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 125, 0, 0
                    , 185.00, 29, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+29, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '5', '29', '0', '4693', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '29', '1', '2022-10-13','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', '450', '26', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '68', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '450';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 450, 0, 0
                    , 280.00, 26, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-26, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2022-02-28*280.00," WHERE transferproductid = 4694;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '1', '26', '1', '4694', 'تحويل منتجات من المخزن', 'storemovementController.php', '94.00', '68', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '910';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 5, 450, 0, 0
                    , 280.00, 26, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '5', '26', '0', '4694', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '28', '1', '2022-10-13','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', '1140', '12', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4162';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1140, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4695;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '1', '12', '1', '4695', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1140', '5', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1140, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '5', '12', '0', '4695', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1138', '12', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4160';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1138, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4696;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '1', '12', '1', '4696', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1138', '5', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1138, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '5', '12', '0', '4696', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1139', '12', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4161';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1139, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4697;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '1', '12', '1', '4697', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1139', '5', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1139, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '5', '12', '0', '4697', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1141', '12', '2022-10-13', '1', '0','1097',null,null,'2022-10-13 21:16:44',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4163';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1141, 0, 0
                    , 250.00, -12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*250.00," WHERE transferproductid = 4698;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '1', '12', '1', '4698', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1141', '5', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1141, 0, 0
                    , 250.00, 12, 0, 0, 1, '2022-10-13 21:16:44')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:16:44' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '5', '12', '0', '4698', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:46:45";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:16:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:16:45', '1', 'editorder', '156.210.21.236', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:49:59";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:19:59", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 21:19:59', '5', '', '197.55.173.253', '', '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-10-13 17:49: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-10-13 17:50:02";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:20:02", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 21:20:02', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:52:21";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:22:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:22:21', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:59:03";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:29:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:29:03', '1', 'add', '156.210.21.236', '', '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(1098,1,3,562,17,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 21:29:03',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1481';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 562, 0, 0
                    , 225.00, -17, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 225.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2022-10-13*225.00," WHERE transferproductid = 4699;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('562', '1', '17', '1', '4699', 'تحويل منتجات من المخزن', 'storemovementController.php', '19.00', '2', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1499';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 562, 0, 0
                    , 225.00, 17, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('562', '3', '17', '0', '4699', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '17', '1', '2022-10-13','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', '386', '15', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '386';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 386, 0, 0
                    , 185.00, -15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 185.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2022-10-13*185.00," WHERE transferproductid = 4700;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('386', '1', '15', '1', '4700', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '-2', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1587';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 386, 0, 0
                    , 185.00, 15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('386', '3', '15', '0', '4700', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '16', '1', '2022-10-13','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', '516', '27', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '516';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 516, 0, 0
                    , 220.00, -27, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2022-10-13*220.00," WHERE transferproductid = 4701;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('516', '1', '27', '1', '4701', 'تحويل منتجات من المخزن', 'storemovementController.php', '27.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1450';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 516, 0, 0
                    , 220.00, 27, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('516', '3', '27', '0', '4701', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '28', '1', '2022-10-13','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', '128', '41', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '128';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 128, 0, 0
                    , 235.00, 26, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-26, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 128, 0, 0
                    , 235.00, -15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 235.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2022-02-28*235.00,15*2022-10-13*235.00," WHERE transferproductid = 4702;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('128', '1', '41', '1', '4702', 'تحويل منتجات من المخزن', 'storemovementController.php', '56.00', '15', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '41', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1460';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 128, 0, 0
                    , 235.00, 26, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 128, 0, 0
                    , 235.00, 15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('128', '3', '41', '0', '4702', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '41', '1', '2022-10-13','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', '125', '21', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '109', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '125';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 125, 0, 0
                    , 185.00, 21, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-21, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2022-02-28*185.00," WHERE transferproductid = 4703;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '1', '21', '1', '4703', 'تحويل منتجات من المخزن', 'storemovementController.php', '130.00', '109', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1459';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 125, 0, 0
                    , 185.00, 21, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '3', '21', '0', '4703', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '21', '1', '2022-10-13','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', '124', '33', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '111', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '124';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 124, 0, 0
                    , 185.00, 33, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-33, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "33*2022-02-28*185.00," WHERE transferproductid = 4704;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '33', '1', '4704', 'تحويل منتجات من المخزن', 'storemovementController.php', '144.00', '111', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1462';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 124, 0, 0
                    , 185.00, 33, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+33, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '3', '33', '0', '4704', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '35', '1', '2022-10-13','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', '561', '23', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '70', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1480';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 561, 0, 0
                    , 210.00, 23, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-23, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2022-02-28*210.00," WHERE transferproductid = 4705;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '23', '1', '4705', 'تحويل منتجات من المخزن', 'storemovementController.php', '93.00', '70', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1504';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 561, 0, 0
                    , 210.00, 23, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '3', '23', '0', '4705', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '23', '1', '2022-10-13','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', '518', '20', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '84', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '518';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 518, 0, 0
                    , 210.00, 20, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-20, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2022-02-28*210.00," WHERE transferproductid = 4706;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '20', '1', '4706', 'تحويل منتجات من المخزن', 'storemovementController.php', '104.00', '84', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1452';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 518, 0, 0
                    , 210.00, 20, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '3', '20', '0', '4706', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '22', '1', '2022-10-13','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', '517', '16', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '55', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '517';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 517, 0, 0
                    , 210.00, 16, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-16, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2022-02-28*210.00," WHERE transferproductid = 4707;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('517', '1', '16', '1', '4707', 'تحويل منتجات من المخزن', 'storemovementController.php', '71.00', '55', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1451';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 517, 0, 0
                    , 210.00, 16, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('517', '3', '16', '0', '4707', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '16', '1', '2022-10-13','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', '1142', '24', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '106', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4164';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1142, 0, 0
                    , 200.00, -24, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2022-10-13*200.00," WHERE transferproductid = 4708;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '1', '24', '1', '4708', 'تحويل منتجات من المخزن', 'storemovementController.php', '130.00', '106', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1142', '3', '24', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1142, 0, 0
                    , 200.00, 24, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '3', '24', '0', '4708', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2022-10-13','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', '514', '32', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '41', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '514';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 514, 0, 0
                    , 210.00, 8, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 514, 0, 0
                    , 210.00, -24, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2022-02-28*210.00,24*2022-10-13*210.00," WHERE transferproductid = 4709;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '1', '32', '1', '4709', 'تحويل منتجات من المخزن', 'storemovementController.php', '73.00', '41', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '33', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1448';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 514, 0, 0
                    , 210.00, 8, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 514, 0, 0
                    , 210.00, 24, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '3', '32', '0', '4709', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '33', '1', '2022-10-13','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', '466', '29', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '101', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '466';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 466, 0, 0
                    , 240.00, 29, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-29, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "29*2022-02-28*240.00," WHERE transferproductid = 4710;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('466', '1', '29', '1', '4710', 'تحويل منتجات من المخزن', 'storemovementController.php', '130.00', '101', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1507';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 466, 0, 0
                    , 240.00, 29, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+29, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('466', '3', '29', '0', '4710', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '29', '1', '2022-10-13','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', '450', '23', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '45', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '450';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 450, 0, 0
                    , 280.00, 23, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-23, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2022-02-28*280.00," WHERE transferproductid = 4711;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '1', '23', '1', '4711', 'تحويل منتجات من المخزن', 'storemovementController.php', '68.00', '45', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1453';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 450, 0, 0
                    , 280.00, 23, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '3', '23', '0', '4711', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '23', '1', '2022-10-13','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', '560', '15', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1479';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 560, 0, 0
                    , 220.00, 10, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 560, 0, 0
                    , 220.00, -5, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2022-02-28*220.00,5*2022-10-13*220.00," WHERE transferproductid = 4712;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '15', '1', '4712', 'تحويل منتجات من المخزن', 'storemovementController.php', '28.00', '13', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1501';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 560, 0, 0
                    , 220.00, 10, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 560, 0, 0
                    , 220.00, 5, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '3', '15', '0', '4712', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '15', '1', '2022-10-13','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', '515', '24', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '515';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 515, 0, 0
                    , 220.00, 9, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 515, 0, 0
                    , 220.00, -15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2022-02-28*220.00,15*2022-10-13*220.00," WHERE transferproductid = 4713;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '1', '24', '1', '4713', 'تحويل منتجات من المخزن', 'storemovementController.php', '43.00', '19', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1449';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 3, 515, 0, 0
                    , 220.00, 9, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 515, 0, 0
                    , 220.00, 15, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '3', '24', '0', '4713', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '24', '1', '2022-10-13','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', '1140', '12', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4162';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1140, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4714;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '1', '12', '1', '4714', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '12', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1140', '3', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1140, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '3', '12', '0', '4714', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1139', '12', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4161';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1139, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4715;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '1', '12', '1', '4715', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '12', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1139', '3', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1139, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '3', '12', '0', '4715', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1138', '12', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4160';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1138, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4716;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '1', '12', '1', '4716', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '12', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1138', '3', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1138, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '3', '12', '0', '4716', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1141', '12', '2022-10-13', '1', '0','1098',null,null,'2022-10-13 21:29:03',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4163';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1141, 0, 0
                    , 250.00, -12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*250.00," WHERE transferproductid = 4717;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '1', '12', '1', '4717', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '12', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1141', '3', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1141, 0, 0
                    , 250.00, 12, 0, 0, 1, '2022-10-13 21:29:03')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:29:03' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '3', '12', '0', '4717', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 17:59:03";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:29:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:29:04', '1', 'editorder', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:03:26";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:33:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:33:26', '1', '', '156.210.21.236', '', '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-10-13 18:06:10";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:36:10", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 21:36:10', '5', '', '197.55.173.253', '', '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-10-13 18:06:10";
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-10-13 18:06:15";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:36:15", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 21:36:15', '5', '', '197.55.173.253', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:07:02";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:37:02", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 21:37:02', '5', '', '197.55.173.253', '', '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-10-13 18:07:03";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:07:10";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:37:10", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 21:37:10', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:07:41";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:37:41", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 21:37:41', '5', 'addsellBill', '197.55.173.253', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:07:51";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:37:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 21:37:51', '5', '', '197.55.173.253', '', '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-10-13 18:07:52";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:26";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:26", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 21:38:26', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:46";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 21:38:46', '5', 'add', '197.55.173.253', '', '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', '-1170901.00', '4000', '1', 'ايصال دفع لمورد', '268', '-1174901', '2022-10-13 21:38:26', '5', 'supplierPayedDeptController.php', 'جمعيه اودي', '0','3', '-1','1','1','1','1');
UPDATE supplier SET  suppliercurrentDebt = '-1174901', userid = '5', supplierdate = '2022-10-13 21:38:46'   WHERE supplierid = '1';
UPDATE save SET  savecurrentvalue = '6015',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10015.00','4000', '1', '3', 'ايصال دفع لمورد', '643', '6015', '2022-10-13 21:38:46', '5',  'supplierPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4000', '4000', '2022-10-13', '5', '0', '0', '2022-10-13 21:38:46','ايصال دفع لمورد ( مباشر ) ','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4938', '168', '4000', '','0');
UPDATE accountstree SET name = 'مباشر', customName = 'مباشر', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '7', mydate = '2021-12-11', itemtype2 = '1', theValue = '-1174901', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '168';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4938', '137', '4000', '','0');
UPDATE accountstree SET name = 'خزينة رائد', customName = 'خزينة رائد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-700555', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
UPDATE supplierdebtchange SET supplierid = '1', supplierdebtchangebefore = '-1170901.00', supplierdebtchangeamount = '4000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '268', supplierdebtchangeafter = '-1174901.00', supplierdebtchangedate = '2022-10-13 21:38:26', userid = '5', tablename = 'supplierPayedDeptController.php', comment = 'جمعيه اودي', dailyentryid = '4938',saveid = '3',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE supplierdebtchangeid = '643';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:46";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:46", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 21:38:46', '5', 'sucess', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:48";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:48", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 21:38:48', '5', 'show', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:48";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:48", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2022-10-13 21:38:48', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:08:51";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:38:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 21:38:51', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:39";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:40:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:40:39', '1', 'add', '156.210.21.236', '', '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(1099,1,6,513,32,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 21:40:39',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '513';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 513, 0, 0
                    , 210.00, 14, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-14, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 513, 0, 0
                    , 210.00, -18, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2022-02-28*210.00,18*2022-10-13*210.00," WHERE transferproductid = 4718;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '1', '32', '1', '4718', 'تحويل منتجات من المخزن', 'storemovementController.php', '51.00', '19', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1047';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 513, 0, 0
                    , 210.00, 14, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 513, 0, 0
                    , 210.00, 18, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '6', '32', '0', '4718', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '32', '1', '2022-10-13','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', '517', '34', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '517';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 517, 0, 0
                    , 210.00, 10, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 517, 0, 0
                    , 210.00, -24, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2022-02-28*210.00,24*2022-10-13*210.00," WHERE transferproductid = 4719;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('517', '1', '34', '1', '4719', 'تحويل منتجات من المخزن', 'storemovementController.php', '55.00', '21', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '34', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1051';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 517, 0, 0
                    , 210.00, 10, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 517, 0, 0
                    , 210.00, 24, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('517', '6', '34', '0', '4719', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '34', '1', '2022-10-13','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', '450', '22', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '450';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 450, 0, 0
                    , 280.00, 22, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-22, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2022-02-28*280.00," WHERE transferproductid = 4720;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '1', '22', '1', '4720', 'تحويل منتجات من المخزن', 'storemovementController.php', '45.00', '23', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1053';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 450, 0, 0
                    , 280.00, 22, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '6', '22', '0', '4720', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '6.00', '28', '1', '2022-10-13','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', '125', '30', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '79', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '125';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 125, 0, 0
                    , 185.00, 30, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-30, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2022-02-28*185.00," WHERE transferproductid = 4721;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '1', '30', '1', '4721', 'تحويل منتجات من المخزن', 'storemovementController.php', '109.00', '79', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1056';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 125, 0, 0
                    , 185.00, 30, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '6', '30', '0', '4721', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '30', '1', '2022-10-13','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', '561', '28', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '42', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1480';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 561, 0, 0
                    , 210.00, 28, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-28, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "28*2022-02-28*210.00," WHERE transferproductid = 4722;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '28', '1', '4722', 'تحويل منتجات من المخزن', 'storemovementController.php', '70.00', '42', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '28', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1492';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 561, 0, 0
                    , 210.00, 28, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+28, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '6', '28', '0', '4722', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '28', '1', '2022-10-13','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', '124', '34', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '77', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '124';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 124, 0, 0
                    , 185.00, 32, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-32, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 124, 0, 0
                    , 185.00, -2, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 185.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2022-02-28*185.00,2*2022-10-13*185.00," WHERE transferproductid = 4723;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '34', '1', '4723', 'تحويل منتجات من المخزن', 'storemovementController.php', '111.00', '77', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '34', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1057';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 124, 0, 0
                    , 185.00, 32, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 124, 0, 0
                    , 185.00, 2, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '6', '34', '0', '4723', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '34', '1', '2022-10-13','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', '518', '20', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '64', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '518';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 518, 0, 0
                    , 210.00, 3, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-3, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 518, 0, 0
                    , 210.00, -17, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2022-02-28*210.00,17*2022-10-13*210.00," WHERE transferproductid = 4724;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '20', '1', '4724', 'تحويل منتجات من المخزن', 'storemovementController.php', '84.00', '64', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1052';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 6, 518, 0, 0
                    , 210.00, 3, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 518, 0, 0
                    , 210.00, 17, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '6', '20', '0', '4724', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '20', '1', '2022-10-13','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', '514', '12', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '514';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 514, 0, 0
                    , 210.00, -12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*210.00," WHERE transferproductid = 4725;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '1', '12', '1', '4725', 'تحويل منتجات من المخزن', 'storemovementController.php', '41.00', '29', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1048';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 514, 0, 0
                    , 210.00, 12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('514', '6', '12', '0', '4725', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2022-10-13','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', '515', '19', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '515';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 515, 0, 0
                    , 220.00, -19, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2022-10-13*220.00," WHERE transferproductid = 4726;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '1', '19', '1', '4726', 'تحويل منتجات من المخزن', 'storemovementController.php', '19.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1049';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 515, 0, 0
                    , 220.00, 19, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('515', '6', '19', '0', '4726', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '19', '1', '2022-10-13','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', '1142', '21', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '85', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4164';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1142, 0, 0
                    , 200.00, -21, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2022-10-13*200.00," WHERE transferproductid = 4727;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '1', '21', '1', '4727', 'تحويل منتجات من المخزن', 'storemovementController.php', '106.00', '85', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1142', '6', '21', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1142, 0, 0
                    , 200.00, 21, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1142', '6', '21', '0', '4727', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '21', '1', '2022-10-13','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', '1134', '13', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4152';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1134, 0, 0
                    , 260.00, -13, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2022-10-13*260.00," WHERE transferproductid = 4728;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1134', '1', '13', '1', '4728', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1134', '6', '13', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1134, 0, 0
                    , 260.00, 13, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1134', '6', '13', '0', '4728', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '13', '1', '2022-10-13','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', '1135', '11', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4153';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1135, 0, 0
                    , 260.00, -11, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-11, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "11*2022-10-13*260.00," WHERE transferproductid = 4729;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1135', '1', '11', '1', '4729', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1135', '6', '11', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1135, 0, 0
                    , 260.00, 11, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+11, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1135', '6', '11', '0', '4729', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '11', '1', '2022-10-13','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', '1138', '12', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4160';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1138, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4730;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '1', '12', '1', '4730', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1138', '6', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1138, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1138', '6', '12', '0', '4730', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1139', '12', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4161';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1139, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4731;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '1', '12', '1', '4731', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1139', '6', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1139, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1139', '6', '12', '0', '4731', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1140', '12', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4162';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1140, 0, 0
                    , 220.00, -12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*220.00," WHERE transferproductid = 4732;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '1', '12', '1', '4732', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1140', '6', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1140, 0, 0
                    , 220.00, 12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1140', '6', '12', '0', '4732', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','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', '1141', '12', '2022-10-13', '1', '0','1099',null,null,'2022-10-13 21:40:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4163';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1141, 0, 0
                    , 250.00, -12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2022-10-13*250.00," WHERE transferproductid = 4733;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '1', '12', '1', '4733', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1141', '6', '12', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1141, 0, 0
                    , 250.00, 12, 0, 0, 1, '2022-10-13 21:40:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:40:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1141', '6', '12', '0', '4733', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:39";
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:40";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:40:40", deviceType = "DESKTOP" WHERE userid = 1;
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:40:40", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:40:40', '1', 'editorder', '156.210.21.236', '', 'DESKTOP');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 21:40:40', '5', 'add', '197.55.173.253', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('3', 'ايجار المحل', '', '3750', '2022-10-13', '5', '0','-1','3','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2265',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('6015.00','3750', '1', '3', 'إضافة مصروف', '1911', '2265', '2022-10-13 21:40:40', '5',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '3750', '3750', '2022-10-13', '5', '0', '0', '2022-10-13 21:40:40','اضافة اسم مصروف( ايجار المحل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4939', '146', '3750', '','0');
UPDATE accountstree SET name = 'ايجار', customName = 'ايجار', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '205475', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '146';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4939', '137', '3750', '','0');
UPDATE accountstree SET name = 'خزينة رائد', customName = 'خزينة رائد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-704305', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
UPDATE expenses SET expensestypeid = '3', expensesname = 'ايجار المحل', expensesdetails = '', expensesValue = '3750.00', expensesdate = '2022-10-13', userid = '5', conditions = '0',saveid = '3' , dailyentryid = '4939', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1911';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:40";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:40:40", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 21:40:40', '5', 'sucess', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:42";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:40:42", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 21:40:42', '5', 'show', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:44";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:40:44", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 21:40:44', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:10:48";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:40:48", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 21:40:48', '5', 'showDetail', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:14:21";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:44:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 21:44:21', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:17:16";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:47:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:47:16', '1', '', '156.210.21.236', '', '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-10-13 18:20:21";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:50:21", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 21:50:21', '5', '', '197.55.173.253', '', '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-10-13 18:20:21";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:20:26";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 21:50:26", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 21:50:26', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:21:01";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:51:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:51:01', '1', 'add', '156.210.21.236', '', '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 ('امهات ابونور','','1','150','150', '190','160', '2022-10-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '150','150','150','150','150','0','0','6.67','26.67','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'امهات ابونور', productDescription = '', productCatId = '1', productBuyPrice = '150', productSellAllPrice = '150', productSellUnitPrice = '190', productSellHalfPrice = '160', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01143',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '150',lastbuyprice_withDiscount = '150',meanbuyprice = '150',meanbuyprice_withDiscount = '150' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '6.67' , buypart_precentage = '26.67',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1143';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1143', '1', '2022-10-13', '1', '0','0114301','150','160','190','150');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1143', '1', '72', '1', '2022-10-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '1', '72', '0', '1143', 'إضافة منتج', 'productController.php', '0', '72', '1', '2022-10-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1143, 1,'2022-10-13 21:51:02',1)
                ON DUPLICATE KEY UPDATE productid = 1143, edited = 1, sysdate = '2022-10-13 21:51:02', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '10800', '10800', '2022-10-13', '1', '0', '0', '2022-10-13 21:51:02','إضافة منتج امهات ابونور الكمية 72','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4940', '19', '10800', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10502655.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4940', '7', '10800', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11271101.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'امهات ابونور', productDescription = '', productCatId = '1', productBuyPrice = '150.00', productSellAllPrice = '150.00', productSellUnitPrice = '190.00', productSellHalfPrice = '160.00', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01143',type ='0', expireDate = '0' , dailyentryId = '4940',isService = '0',isOptic = '0',lastbuyprice = '150',lastbuyprice_withDiscount = '150',meanbuyprice = '150',meanbuyprice_withDiscount = '150' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '6.67' , buypart_precentage = '26.67',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1143';
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 ('هايدي ابو انور','','1','225','225', '265','245', '2022-10-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '225','225','225','225','225','0','0','8.89','17.78','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'هايدي ابو انور', productDescription = '', productCatId = '1', productBuyPrice = '225', productSellAllPrice = '225', productSellUnitPrice = '265', productSellHalfPrice = '245', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01144',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225',lastbuyprice_withDiscount = '225',meanbuyprice = '225',meanbuyprice_withDiscount = '225' , productbuypricereal = '225' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '8.89' , buypart_precentage = '17.78',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1144';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1144', '1', '2022-10-13', '1', '0','0114401','225','245','265','225');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1144', '1', '81', '1', '2022-10-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '1', '81', '0', '1144', 'إضافة منتج', 'productController.php', '0', '81', '1', '2022-10-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1144, 1,'2022-10-13 21:51:02',1)
                ON DUPLICATE KEY UPDATE productid = 1144, edited = 1, sysdate = '2022-10-13 21:51:02', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '18225', '18225', '2022-10-13', '1', '0', '0', '2022-10-13 21:51:02','إضافة منتج هايدي ابو انور الكمية 81','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4941', '19', '18225', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10520880.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4941', '7', '18225', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11289326.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'هايدي ابو انور', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '225.00', productSellUnitPrice = '265.00', productSellHalfPrice = '245.00', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01144',type ='0', expireDate = '0' , dailyentryId = '4941',isService = '0',isOptic = '0',lastbuyprice = '225',lastbuyprice_withDiscount = '225',meanbuyprice = '225',meanbuyprice_withDiscount = '225' , productbuypricereal = '225' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '8.89' , buypart_precentage = '17.78',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1144';
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 ('كوري ابونور','','1','270','270', '310','290', '2022-10-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '270','270','270','270','270','0','0','7.41','14.81','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'كوري ابونور', productDescription = '', productCatId = '1', productBuyPrice = '270', productSellAllPrice = '270', productSellUnitPrice = '310', productSellHalfPrice = '290', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01145',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '7.41' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1145';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1145', '1', '2022-10-13', '1', '0','0114501','270','290','310','270');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1145', '1', '90', '1', '2022-10-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '1', '90', '0', '1145', 'إضافة منتج', 'productController.php', '0', '90', '1', '2022-10-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1145, 1,'2022-10-13 21:51:02',1)
                ON DUPLICATE KEY UPDATE productid = 1145, edited = 1, sysdate = '2022-10-13 21:51:02', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '24300', '24300', '2022-10-13', '1', '0', '0', '2022-10-13 21:51:02','إضافة منتج كوري ابونور الكمية 90','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4942', '19', '24300', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '10545180.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4942', '7', '24300', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '11313626.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'كوري ابونور', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270.00', productSellUnitPrice = '310.00', productSellHalfPrice = '290.00', productDate = '2022-10-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01145',type ='0', expireDate = '0' , dailyentryId = '4942',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '7.41' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1145';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:21:03";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:51:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 21:51:04', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:21:11";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:51:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:51:11', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:23:36";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:53:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:53:36', '1', 'add', '156.210.21.236', '', '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(1100,1,5,1143,24,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 21:53:36',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '48', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4183';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1143, 0, 0
                    , 150.00, -24, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyprice = 150.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2022-10-13*150.00," WHERE transferproductid = 4734;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '1', '24', '1', '4734', 'تحويل منتجات من المخزن', 'storemovementController.php', '72.00', '48', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1143', '5', '24', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1143, 0, 0
                    , 150.00, 24, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '5', '24', '0', '4734', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2022-10-13','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', '1144', '27', '2022-10-13', '1', '0','1100',null,null,'2022-10-13 21:53:36',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '54', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4184';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1144, 0, 0
                    , 225.00, -27, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyprice = 225.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2022-10-13*225.00," WHERE transferproductid = 4735;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '1', '27', '1', '4735', 'تحويل منتجات من المخزن', 'storemovementController.php', '81.00', '54', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1144', '5', '27', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1144, 0, 0
                    , 225.00, 27, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '5', '27', '0', '4735', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '27', '1', '2022-10-13','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', '1145', '30', '2022-10-13', '1', '0','1100',null,null,'2022-10-13 21:53:36',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '60', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4185';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1145, 0, 0
                    , 270.00, -30, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2022-10-13*270.00," WHERE transferproductid = 4736;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '1', '30', '1', '4736', 'تحويل منتجات من المخزن', 'storemovementController.php', '90.00', '60', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1145', '5', '30', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 5, 1145, 0, 0
                    , 270.00, 30, 0, 0, 1, '2022-10-13 21:53:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:53:36' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '5', '30', '0', '4736', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:23:36";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:53:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:53:37', '1', 'editorder', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:25:13";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:55:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:55:13', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:26:38";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:56:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:56:39', '1', 'add', '156.210.21.236', '', '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(1101,1,3,1143,24,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 21:56:39',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4183';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1143, 0, 0
                    , 150.00, -24, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyprice = 150.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2022-10-13*150.00," WHERE transferproductid = 4737;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '1', '24', '1', '4737', 'تحويل منتجات من المخزن', 'storemovementController.php', '48.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1143', '3', '24', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1143, 0, 0
                    , 150.00, 24, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '3', '24', '0', '4737', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2022-10-13','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', '1144', '27', '2022-10-13', '1', '0','1101',null,null,'2022-10-13 21:56:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4184';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1144, 0, 0
                    , 225.00, -27, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyprice = 225.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2022-10-13*225.00," WHERE transferproductid = 4738;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '1', '27', '1', '4738', 'تحويل منتجات من المخزن', 'storemovementController.php', '54.00', '27', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1144', '3', '27', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1144, 0, 0
                    , 225.00, 27, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '3', '27', '0', '4738', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '27', '1', '2022-10-13','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', '1145', '30', '2022-10-13', '1', '0','1101',null,null,'2022-10-13 21:56:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4185';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1145, 0, 0
                    , 270.00, -30, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2022-10-13*270.00," WHERE transferproductid = 4739;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '1', '30', '1', '4739', 'تحويل منتجات من المخزن', 'storemovementController.php', '60.00', '30', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1145', '3', '30', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 3, 1145, 0, 0
                    , 270.00, 30, 0, 0, 1, '2022-10-13 21:56:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 21:56:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '3', '30', '0', '4739', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:26:39";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:56:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:56:39', '1', 'editorder', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:28:39";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 21:58:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 21:58:39', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:32:22";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:02:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:02:22', '1', 'add', '156.210.21.236', '', '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(1102,1,6,1143,24,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 22:02:22',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4183';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1143, 0, 0
                    , 150.00, -24, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyprice = 150.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2022-10-13*150.00," WHERE transferproductid = 4740;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '1', '24', '1', '4740', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1143', '6', '24', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1143, 0, 0
                    , 150.00, 24, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1143', '6', '24', '0', '4740', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2022-10-13','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', '1144', '27', '2022-10-13', '1', '0','1102',null,null,'2022-10-13 22:02:22',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4184';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1144, 0, 0
                    , 225.00, -27, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyprice = 225.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2022-10-13*225.00," WHERE transferproductid = 4741;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '1', '27', '1', '4741', 'تحويل منتجات من المخزن', 'storemovementController.php', '27.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1144', '6', '27', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1144, 0, 0
                    , 225.00, 27, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1144', '6', '27', '0', '4741', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '27', '1', '2022-10-13','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', '1145', '30', '2022-10-13', '1', '0','1102',null,null,'2022-10-13 22:02:22',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '4185';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 1145, 0, 0
                    , 270.00, -30, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2022-10-13*270.00," WHERE transferproductid = 4742;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '1', '30', '1', '4742', 'تحويل منتجات من المخزن', 'storemovementController.php', '30.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1145', '6', '30', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 6, 1145, 0, 0
                    , 270.00, 30, 0, 0, 1, '2022-10-13 22:02:22')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:02:22' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1145', '6', '30', '0', '4742', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:32:23";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:02:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:02:23', '1', 'editorder', '156.210.21.236', '', '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-10-13 18:38:50";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:08:50", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 22:08:50', '5', '', '197.55.173.253', '', '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-10-13 18:38:50";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:38:54";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:08:54", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:08:54', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:53:04";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:23:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventorybybarcodeController.php', '2022-10-13 22:23:04', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:53:23";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:23:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('unitController.php', '2022-10-13 22:23:23', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:54:29";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:24:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 22:24:29', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:54:43";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:24:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 22:24:43', '1', 'add', '156.210.21.236', '', 'DESKTOP');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment) VALUES ('7','9', '3500', '2022-10-13', '1', '0', '0','');
UPDATE save SET  savecurrentvalue = '27',  userid = '1' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3527.00','3500', '1', '7', 'تحويل امول الى الخزنة  [ الشيخ وليد ] ', '347', '27', '2022-10-13 22:24:43', '1',  'transfermoneyController.php','0','');
UPDATE save SET  savecurrentvalue = '3575370',  userid = '1' WHERE saveid = '9';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3571870.00','3500', '0', '9', 'تحويل امول من الخزنة  [ خزينة محل العميد ] ', '347', '3575370', '2022-10-13 22:24:43', '1',  'transfermoneyController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '3500', '3500', '2022-10-13', '1', '0', '0', '2022-10-13 22:24:43','اضافة تحويل من خزينة محل العميد الى الشيخ وليد','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4943', '156', '3500', '','0');
UPDATE accountstree SET name = 'الشيخ وليد', customName = 'الشيخ وليد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-09', itemtype2 = '1', theValue = '3575370', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '156';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4943', '141', '3500', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-934560', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE transfermoney SET saveidfrom = '7', saveidto = '9', transfermoneyvalue = '3500.00', transfermoneydate = '2022-10-13', userid = '1', conditions = '0' , dailyentryid = '4943' , comment = '' WHERE transfermoneyid = '347';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:54:47";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:24:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 22:24:47', '1', 'sucess', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:54:49";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:24:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 22:24:49', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:54:53";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:24:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2022-10-13 22:24:53', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:55:11";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:25:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:25:11', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:57:12";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:27:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2022-10-13 22:27:12', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:57:30";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:27:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2022-10-13 22:27:30', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:58:05";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:28:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailpriceController.php', '2022-10-13 22:28:05', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:58:28";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:28:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailpriceController.php', '2022-10-13 22:28:28', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:58:52";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:28:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:28:52', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 18:59:17";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:29:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:29:17', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE product SET productName = 'ديجيتال 633', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '150.00', productSellUnitPrice = '180.00', productSellHalfPrice = '160.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00382',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '172.5',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '382';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (382, 1,'2022-10-13 22:29:33',1)
                ON DUPLICATE KEY UPDATE productid = 382, edited = 1, sysdate = '2022-10-13 22:29:33', userid = 1;
UPDATE product SET productName = 'ديجيتال 633', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00382',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '172.50',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '382';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (382, 1,'2022-10-13 22:29:36',1)
                ON DUPLICATE KEY UPDATE productid = 382, edited = 1, sysdate = '2022-10-13 22:29:36', userid = 1;
UPDATE product SET productName = 'ديجيتال 633', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00382',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '172.50',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '382';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (382, 1,'2022-10-13 22:29:39',1)
                ON DUPLICATE KEY UPDATE productid = 382, edited = 1, sysdate = '2022-10-13 22:29:39', userid = 1;
UPDATE product SET productName = 'ديجيتال 633', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '215', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00382',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '172.50',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.67' , 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 = '382';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (382, 1,'2022-10-13 22:29:49',1)
                ON DUPLICATE KEY UPDATE productid = 382, edited = 1, sysdate = '2022-10-13 22:29:49', userid = 1;
UPDATE user SET loginip = "" WHERE userid = 5;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:00:01";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:30:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:30:01', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:00:14";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:30:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:30:15', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 382;
UPDATE productunit SET unitid = '1', productid = '382', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038201',proUnitSellAllPrice='200',proUnitSellHalfPrice='240',proUnitSellUnitPrice ='240',proUnitBuyPrice='190' WHERE productunitid = '382';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (382, 1,'2022-10-13 22:30:15',1)
                ON DUPLICATE KEY UPDATE productid = 382, edited = 1, sysdate = '2022-10-13 22:30:15', userid = 1;
UPDATE product SET productName = 'ديجيتال 633', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00382',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190.00',lastbuyprice_withDiscount = '190',meanbuyprice = '172.50',meanbuyprice_withDiscount = '172.5' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '6.67' , buypart_precentage = '20',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '382';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:00:22";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:30:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:30:22', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:00:33";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:30:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:30:33', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:01:00";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:31:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:31:00', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:01:10";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:31:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:31:10', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:01:12";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:31:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:31:13', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:01:45";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:31:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:31:45', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 383;
UPDATE productunit SET unitid = '1', productid = '383', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038301',proUnitSellAllPrice='210',proUnitSellHalfPrice='210',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '383';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (383, 1,'2022-10-13 22:31:45',1)
                ON DUPLICATE KEY UPDATE productid = 383, edited = 1, sysdate = '2022-10-13 22:31:45', userid = 1;
UPDATE product SET productName = 'ديجيتال 634', productDescription = '', productCatId = '1', productBuyPrice = '150', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00383',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '167.50',meanbuyprice_withDiscount = '167.5' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '16.67' , buyhalf_precentage = '30' , buypart_precentage = '43.33',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '383';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:01:47";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:31:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:31:47', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:09";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:09', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:11";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:11', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:28";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:28', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 384;
UPDATE productunit SET unitid = '1', productid = '384', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038401',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '384';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (384, 1,'2022-10-13 22:32:29',1)
                ON DUPLICATE KEY UPDATE productid = 384, edited = 1, sysdate = '2022-10-13 22:32:29', userid = 1;
UPDATE product SET productName = 'ديجيتال 635', productDescription = '', productCatId = '1', productBuyPrice = '150', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00384',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '167.50',meanbuyprice_withDiscount = '167.5' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '16.67' , buyhalf_precentage = '30' , buypart_precentage = '43.33',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '384';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:30";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:30', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:43";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:43', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:02:45";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:32:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:32:45', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:03:23";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:33:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:33:23', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 385;
UPDATE productunit SET unitid = '1', productid = '385', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038501',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '385';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (385, 1,'2022-10-13 22:33:23',1)
                ON DUPLICATE KEY UPDATE productid = 385, edited = 1, sysdate = '2022-10-13 22:33:23', userid = 1;
UPDATE product SET productName = 'ديجيتال 636', productDescription = '', productCatId = '1', productBuyPrice = '150', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00385',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '167.50',meanbuyprice_withDiscount = '167.5' , productbuypricereal = '150' , buypricereal_precentage = '0' , buytotal_precentage = '16.67' , buyhalf_precentage = '30' , buypart_precentage = '43.33',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '385';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:03:25";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:33:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:33:25', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:03:38";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:33:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:33:38', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:03:40";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:33:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:33:40', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:07";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:07', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 386;
UPDATE productunit SET unitid = '1', productid = '386', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038601',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2022-10-13 22:34:07',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2022-10-13 22:34:07', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '962.27',meanbuyprice_withDiscount = '962.27' , productbuypricereal = '175' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '11.43' , buypart_precentage = '22.86',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '386';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:09";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:09', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:19";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:19', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:23";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:23', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:44";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:44', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 387;
UPDATE productunit SET unitid = '1', productid = '387', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0038701',proUnitSellAllPrice='190',proUnitSellHalfPrice='190',proUnitSellUnitPrice ='240',proUnitBuyPrice='175' WHERE productunitid = '387';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (387, 1,'2022-10-13 22:34:45',1)
                ON DUPLICATE KEY UPDATE productid = 387, edited = 1, sysdate = '2022-10-13 22:34:45', userid = 1;
UPDATE product SET productName = 'ديجيتال 638', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00387',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '168.75',meanbuyprice_withDiscount = '168.75' , productbuypricereal = '175' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '11.43' , buypart_precentage = '22.86',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '387';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:04:46";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:34:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:34:46', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:05:15";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:35:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:35:15', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '160.00', productSellUnitPrice = '190.00', productSellHalfPrice = '170.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:35:35',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:35:35', userid = 1;
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175', productSellUnitPrice = '175', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:35:37',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:35:37', userid = 1;
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '175.00', productSellHalfPrice = '175', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:35:43',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:35:43', userid = 1;
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '215', productSellHalfPrice = '175.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:35:48',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:35:48', userid = 1;
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175.00', productSellAllPrice = '175.00', productSellUnitPrice = '215.00', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '160.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:35:52',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:35:52', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:05:52";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:35:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:35:52', '1', 'edit', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:06:04";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:36:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:36:04', '1', 'update', '156.210.21.236', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 390;
UPDATE productunit SET unitid = '1', productid = '390', productnumber = '1.00', productunitdate = '2022-10-13', userid = '1', conditions = '0',proUnitParcode='0039001',proUnitSellAllPrice='190',proUnitSellHalfPrice='190',proUnitSellUnitPrice ='230',proUnitBuyPrice='175' WHERE productunitid = '390';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (390, 1,'2022-10-13 22:36:04',1)
                ON DUPLICATE KEY UPDATE productid = 390, edited = 1, sysdate = '2022-10-13 22:36:04', userid = 1;
UPDATE product SET productName = 'ديجيتال الوليد', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '175', productSellUnitPrice = '215', productSellHalfPrice = '195', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00390',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '171.25',meanbuyprice_withDiscount = '171.25' , productbuypricereal = '175' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '6.25' , buypart_precentage = '18.75',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '390';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:06:06";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:36:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2022-10-13 22:36:06', '1', 'show', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:06:09";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:36:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:36:09', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:06:25";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:36:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:36:25', '1', 'addsellBill', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:04";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:05', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:27";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:27', '7', 'add', '197.192.205.152', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'عمادحمدي', '', '70', '2022-10-13', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3940',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4010.00','70', '1', '5', 'إضافة مصروف', '1912', '3940', '2022-10-13 22:40:27', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '70', '70', '2022-10-13', '7', '0', '0', '2022-10-13 22:40:27','اضافة اسم مصروف( عمادحمدي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4944', '145', '70', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '264265', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4944', '139', '70', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1147799', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'عمادحمدي', expensesdetails = '', expensesValue = '70.00', expensesdate = '2022-10-13', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '4944', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1912';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:28";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:28', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:39";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:40', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:43";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:43", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:43', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:56";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:56', '7', 'add', '197.192.205.152', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'عبدالله', '', '700', '2022-10-13', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '3240',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3940.00','700', '1', '5', 'إضافة مصروف', '1913', '3240', '2022-10-13 22:40:56', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '700', '700', '2022-10-13', '7', '0', '0', '2022-10-13 22:40:56','اضافة اسم مصروف( عبدالله )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4945', '145', '700', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '264965', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4945', '139', '700', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1148499', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'عبدالله', expensesdetails = '', expensesValue = '700.00', expensesdate = '2022-10-13', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '4945', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1913';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:56";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:56', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:10:58";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:40:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:40:58', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:11:52";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:41:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:41:52', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:12:10";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:42:10", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:42:10', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:12:37";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:42:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:42:37', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:13:11";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:43:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:43:11', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:14:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:44:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:44:08', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:15:24";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:45:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:45:24', '7', 'add', '197.192.205.152', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('7', 'الشيخ وليد', 'طلبات تبع الشيخ وليد', '650', '2022-10-13', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2590',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3240.00','650', '1', '5', 'إضافة مصروف', '1914', '2590', '2022-10-13 22:45:24', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '650', '650', '2022-10-13', '7', '0', '0', '2022-10-13 22:45:24','اضافة اسم مصروف( الشيخ وليد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4946', '150', '650', '','0');
UPDATE accountstree SET name = 'ضيافة', customName = 'ضيافة', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '7030', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '150';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4946', '139', '650', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1149149', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '7', expensesname = 'الشيخ وليد', expensesdetails = 'طلبات تبع الشيخ وليد', expensesValue = '650.00', expensesdate = '2022-10-13', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '4946', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1914';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:15:25";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:45:25", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:45:25', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:15:28";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:45:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 22:45:28', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:15:32";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:45:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:45:32', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:16:06";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:46:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:46:06', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:16:19";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:46:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:46:19', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:17:07";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:47:07", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:47:07', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:17:33";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:47:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2022-10-13 22:47:33', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:18:25";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:48:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:48:25', '1', 'add', '156.210.21.236', '', '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(1103,1,7,251,17,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 22:48:25',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '251';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 251, 0, 0
                    , 210.00, -17, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2022-10-13*210.00," WHERE transferproductid = 4743;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('251', '1', '17', '1', '4743', 'تحويل منتجات من المخزن', 'storemovementController.php', '34.00', '17', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1838';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 251, 0, 0
                    , 210.00, 17, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('251', '7', '17', '0', '4743', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '17', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '255', '7', '2022-10-13', '1', '0','1103',null,null,'2022-10-13 22:48:25',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '255';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 255, 0, 0
                    , 255.00, -7, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 255.00,
                        buyQuantity =buyQuantity+-7, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "7*2022-10-13*255.00," WHERE transferproductid = 4744;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('255', '1', '7', '1', '4744', 'تحويل منتجات من المخزن', 'storemovementController.php', '5.00', '-2', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1745';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 255, 0, 0
                    , 255.00, 7, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+7, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('255', '7', '7', '0', '4744', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '7', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '253', '11', '2022-10-13', '1', '0','1103',null,null,'2022-10-13 22:48:25',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '253';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 1, 253, 0, 0
                    , 225.00, 8, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-8, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 253, 0, 0
                    , 225.00, -3, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 225.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2022-02-27*225.00,3*2022-10-13*225.00," WHERE transferproductid = 4745;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('253', '1', '11', '1', '4745', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1556';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-27', 7, 253, 0, 0
                    , 225.00, 8, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 253, 0, 0
                    , 225.00, 3, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('253', '7', '11', '0', '4745', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '11', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '513', '19', '2022-10-13', '1', '0','1103',null,null,'2022-10-13 22:48:25',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '513';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 513, 0, 0
                    , 210.00, -19, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2022-10-13*210.00," WHERE transferproductid = 4746;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '1', '19', '1', '4746', 'تحويل منتجات من المخزن', 'storemovementController.php', '19.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1297';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 513, 0, 0
                    , 210.00, 19, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('513', '7', '19', '0', '4746', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '12.00', '31', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '124', '34', '2022-10-13', '1', '0','1103',null,null,'2022-10-13 22:48:25',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '43', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '124';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 124, 0, 0
                    , 185.00, -34, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 185.00,
                        buyQuantity =buyQuantity+-34, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "34*2022-10-13*185.00," WHERE transferproductid = 4747;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '34', '1', '4747', 'تحويل منتجات من المخزن', 'storemovementController.php', '77.00', '43', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '34', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1306';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 124, 0, 0
                    , 185.00, 34, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+34, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '7', '34', '0', '4747', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '34', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '252', '15', '2022-10-13', '1', '0','1103',null,null,'2022-10-13 22:48:25',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '252';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 252, 0, 0
                    , 235.00, 1, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 252, 0, 0
                    , 235.00, -14, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyprice = 235.00,
                        buyQuantity =buyQuantity+-14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2022-02-28*235.00,14*2022-10-13*235.00," WHERE transferproductid = 4748;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('252', '1', '15', '1', '4748', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('252', '7', '15', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 7, 252, 0, 0
                    , 235.00, 1, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 7, 252, 0, 0
                    , 235.00, 14, 0, 0, 1, '2022-10-13 22:48:25')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:48:25' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('252', '7', '15', '0', '4748', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '15', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:18:25";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:48:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:48:25', '1', 'editshow', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:19:53";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:49:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:49:53', '1', '', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:21:30";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:51:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:51:30', '1', 'add', '156.210.21.236', '', '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(1104,1,8,450,23,'2022-10-13',1,0, '' ,0,0,0,0,0,'2022-10-13 22:51:30',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '450';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 450, 0, 0
                    , 280.00, 21, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-21, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 450, 0, 0
                    , 280.00, -2, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyprice = 280.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2022-02-28*280.00,2*2022-10-13*280.00," WHERE transferproductid = 4749;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '1', '23', '1', '4749', 'تحويل منتجات من المخزن', 'storemovementController.php', '23.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1945';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 8, 450, 0, 0
                    , 280.00, 21, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 8, 450, 0, 0
                    , 280.00, 2, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('450', '8', '23', '0', '4749', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '561', '15', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1480';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 561, 0, 0
                    , 210.00, 15, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-15, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2022-02-28*210.00," WHERE transferproductid = 4750;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '1', '15', '1', '4750', 'تحويل منتجات من المخزن', 'storemovementController.php', '42.00', '27', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1520';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 8, 561, 0, 0
                    , 210.00, 15, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('561', '8', '15', '0', '4750', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '8.00', '23', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '125', '10', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '69', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '125';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 1, 125, 0, 0
                    , 185.00, 10, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2022-02-28*185.00," WHERE transferproductid = 4751;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '1', '10', '1', '4751', 'تحويل منتجات من المخزن', 'storemovementController.php', '79.00', '69', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('125', '8', '10', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-02-28', 8, 125, 0, 0
                    , 185.00, 10, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('125', '8', '10', '0', '4751', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '10', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '560', '13', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1479';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 560, 0, 0
                    , 220.00, -13, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyprice = 220.00,
                        buyQuantity =buyQuantity+-13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2022-10-13*220.00," WHERE transferproductid = 4752;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '1', '13', '1', '4752', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1486';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 8, 560, 0, 0
                    , 220.00, 13, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('560', '8', '13', '0', '4752', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '3.00', '16', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '124', '19', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '124';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 124, 0, 0
                    , 185.00, -19, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyprice = 185.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2022-10-13*185.00," WHERE transferproductid = 4753;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '1', '19', '1', '4753', 'تحويل منتجات من المخزن', 'storemovementController.php', '43.00', '24', '1', '2022-10-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('124', '8', '19', '1', '2022-10-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 8, 124, 0, 0
                    , 185.00, 19, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('124', '8', '19', '0', '4753', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '19', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '128', '15', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '128';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 128, 0, 0
                    , 235.00, -15, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyprice = 235.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2022-10-13*235.00," WHERE transferproductid = 4754;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('128', '1', '15', '1', '4754', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1191';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 8, 128, 0, 0
                    , 235.00, 15, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('128', '8', '15', '0', '4754', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '4.00', '19', '1', '2022-10-13','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '556', '13', '2022-10-13', '1', '0','1104',null,null,'2022-10-13 22:51:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1469';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 1, 556, 0, 0
                    , 195.00, -13, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyprice = 195.00,
                        buyQuantity =buyQuantity+-13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "13*2022-10-13*195.00," WHERE transferproductid = 4755;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '1', '13', '1', '4755', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2022-10-13','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2022-10-13' WHERE storedetailid = '1477';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2022-10-13', 8, 556, 0, 0
                    , 195.00, 13, 0, 0, 1, '2022-10-13 22:51:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+13, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2022-10-13 22:51:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '8', '13', '0', '4755', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2022-10-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:21:30";
UPDATE user SET loginip = "156.210.21.236", lastactivetime = "2022-10-13 22:51:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2022-10-13 22:51:30', '1', 'editshow', '156.210.21.236', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:21:44";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:51:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 22:51:44', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:21:50";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:51:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 22:51:50', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:22:40";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:52:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 22:52:41', '7', 'add', '197.192.205.152', '', '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', '-1174901.00', '2000', '1', 'ايصال دفع لمورد', '269', '-1176901', '2022-10-13 22:51:50', '7', 'supplierPayedDeptController.php', 'جمعيه اودي', '0','5', '-1','1','1','1','1');
UPDATE supplier SET  suppliercurrentDebt = '-1176901', userid = '7', supplierdate = '2022-10-13 22:52:41'   WHERE supplierid = '1';
UPDATE save SET  savecurrentvalue = '590',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2590.00','2000', '1', '5', 'ايصال دفع لمورد', '644', '590', '2022-10-13 22:52:41', '7',  'supplierPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '2000', '2000', '2022-10-13', '7', '0', '0', '2022-10-13 22:52:41','ايصال دفع لمورد ( مباشر ) ','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4947', '168', '2000', '','0');
UPDATE accountstree SET name = 'مباشر', customName = 'مباشر', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '7', mydate = '2021-12-11', itemtype2 = '1', theValue = '-1176901', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '168';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4947', '139', '2000', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-1151149', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE supplierdebtchange SET supplierid = '1', supplierdebtchangebefore = '-1174901.00', supplierdebtchangeamount = '2000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '269', supplierdebtchangeafter = '-1176901.00', supplierdebtchangedate = '2022-10-13 22:51:50', userid = '7', tablename = 'supplierPayedDeptController.php', comment = 'جمعيه اودي', dailyentryid = '4947',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE supplierdebtchangeid = '644';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:22:41";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:52:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 22:52:42', '7', 'sucess', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:22:53";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:52:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierPayedDeptController.php', '2022-10-13 22:52:53', '7', 'show', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:22:54";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:52:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2022-10-13 22:52:54', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:22:56";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:52:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:52:56', '7', '', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:23:01";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:53:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:53:01', '7', 'showDetail', '197.192.205.152', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:23:08";
UPDATE user SET loginip = "197.192.205.152", lastactivetime = "2022-10-13 22:53:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:53:08', '7', 'addsellBill', '197.192.205.152', '', '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-10-13 19:23:51";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:53:51", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 22:53:51', '5', '', '197.55.173.253', '', '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-10-13 19:23:51";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:23:55";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:53:55", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:53:55', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:24:08";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:54:08", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:54:08', '5', 'showDetail', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:24:37";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:54:37", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:54:37', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:25:04";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:55:04", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 22:55:04', '5', 'showDetail', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:25:22";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:55:22", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:55:22', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:25:36";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 22:55:36", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 22:55:36', '5', 'showDetail', '197.55.173.253', '', '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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:40:45";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:10:45", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2022-10-13 23:10:46', '5', '', '197.55.173.253', '', '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-10-13 19:40:46";
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-10-13 19:41:00";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:11:00", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2022-10-13 23:11:00', '5', 'addsellBill', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:41:16";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:11:16", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 23:11:16', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:42:00";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:12:00", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 23:12:01', '5', 'add', '197.55.173.253', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'توكتوك نقل بضاعه ', '', '20', '2022-10-13', '5', '0','-1','3','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2245',  userid = '5' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2265.00','20', '1', '3', 'إضافة مصروف', '1915', '2245', '2022-10-13 23:12:01', '5',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2022-10-13', '5', '0', '0', '2022-10-13 23:12:01','اضافة اسم مصروف( توكتوك نقل بضاعه  )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4948', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-781310', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('4948', '137', '20', '','0');
UPDATE accountstree SET name = 'خزينة رائد', customName = 'خزينة رائد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-704325', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '137';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'توكتوك نقل بضاعه ', expensesdetails = '', expensesValue = '20.00', expensesdate = '2022-10-13', userid = '5', conditions = '0',saveid = '3' , dailyentryid = '4948', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '1915';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:42:01";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:12:01", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 23:12:01', '5', 'sucess', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:42:03";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:12:03", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2022-10-13 23:12:03', '5', 'show', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:42:06";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:12:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 23:12:06', '5', '', '197.55.173.253', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2022-10-13 19:42:09";
UPDATE user SET loginip = "197.55.173.253", lastactivetime = "2022-10-13 23:12:09", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2022-10-13 23:12:09', '5', 'showDetail', '197.55.173.253', '', 'DESKTOP');
