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

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:46:00";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:16:01", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 09:16:01', '3', 'addsellBill', '197.32.200.79', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:46:51";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:16:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 09:16:51', '3', 'addAndRetuen', '197.32.200.79', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668e2721276ec
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 09:16:01', '0668e2721276ec', '1', '0.00', '0', '0', '1', '440', '440', '440', '0', '8', '2024-07-10 09:16:51', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','440','0','','0','0','440','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17782', '0', '2024-07-10 09:16:51', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17095;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('480','01585', '17782', '1', '1585', '1', '440.02', '440', '0', '', '2', '2024-07-10 09:16:51', '1585', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','17095-1,');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 455.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 455.00
                where sellbilldetailid = 52665;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1585, '2024-07-10', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '3', storedetaildate = '2024-07-10 09:16:51' WHERE storedetailid = '5783';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1585', '8', '1', '1', '17782', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31.00', '30', '3', '2024-07-10 09:16:51','0','0');
UPDATE save SET  savecurrentvalue = '24475',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('24035.00','440', '0', '8', 'اضافة فاتورة مبيعات', '17782', '24475', '2024-07-10 09:16:51', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 440, 430, 480
                    , 455, 480, 455, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 440, 430, 480
                    , 455, 480, 455, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+440, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+480
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+455
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+480
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+455
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668e2721276ec and sellbillId = 17782 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:46:52";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:16:52", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 09:16:52', '3', 'addsellBill', '197.32.200.79', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:51:23";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:21:23", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 09:21:23', '3', 'addAndRetuen', '197.32.200.79', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668e27546a7d8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 09:16:52', '0668e27546a7d8', '1', '0.00', '0', '50', '1', '4070', '4020', '4020', '0', '8', '2024-07-10 09:21:23', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '10' ,'0','','','','','-1','0','0','0','0','0','4020','0','','0','0','4020','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17783', '0', '2024-07-10 09:21:23', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4020', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17783', '1', '1780', '1', '330', '330', '0', '', '1', '2024-07-10 09:21:23', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19445-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 52666;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '31', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32.00', '31', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19439;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17783', '1', '1577', '1', '530', '530', '0', '', '1', '2024-07-10 09:21:23', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19439-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52667;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37.00', '36', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17783', '1', '1780', '1', '330', '330', '0', '', '1', '2024-07-10 09:21:23', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19445-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 52668;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31.00', '30', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17783', '1', '1780', '1', '330', '330', '0', '', '1', '2024-07-10 09:21:23', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19445-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 52669;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '29', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30.00', '29', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18165;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('240','01230', '17783', '1', '1230', '1', '300', '300', '0', '', '1', '2024-07-10 09:21:23', '1230', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18165-1,');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
                where sellbilldetailid = 52670;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1230, '2024-07-10', 296.3144963145, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+296.3144963145, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 296.3144963145, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+296.3144963145, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '4676';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1230', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19439;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17783', '1', '1577', '1', '530', '530', '0', '', '1', '2024-07-10 09:21:23', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19439-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52671;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '35', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36.00', '35', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17783', '1', '1770', '2', '430', '860', '0', '', '1', '2024-07-10 09:21:23', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19037-2,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52672;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-07-10', 849.43488943489, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+849.43488943489, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 849.43488943489, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+849.43488943489, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '2', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '7', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19439;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17783', '1', '1577', '1', '530', '530', '0', '', '1', '2024-07-10 09:21:23', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19439-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52673;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 523.48894348894, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+523.48894348894, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '34', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35.00', '34', '3', '2024-07-10 09:21:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17783', '1', '1780', '1', '330', '330', '0', '', '1', '2024-07-10 09:21:23', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19445-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 52674;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-07-10', 325.94594594595, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.94594594595, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '28', userid = '3', storedetaildate = '2024-07-10 09:21:23' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17783', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29.00', '28', '3', '2024-07-10 09:21:23','0','0');
UPDATE save SET  savecurrentvalue = '28495',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('24475.00','4020', '0', '8', 'اضافة فاتورة مبيعات', '17783', '28495', '2024-07-10 09:21:23', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 4020, 3290, 3290
                    , 3290, 3290, 3290, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4020, sellCostBuyPrice =sellCostBuyPrice+3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 4020, 3290, 3290
                    , 3290, 3290, 3290, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4020, sellCostBuyPrice =sellCostBuyPrice+3290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3290
                            , 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, 4020, 3290, 3290
                    , 3290, 3290, 3290, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4020, netSellCostBuyPrice = netSellCostBuyPrice+3290
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3290
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3290
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3290
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3290
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668e27546a7d8 and sellbillId = 17783 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:51:24";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:21:24", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 09:21:24', '3', 'addsellBill', '197.32.200.79', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 05:51:26";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 09:21:26", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 09:21:26', '3', '', '197.32.200.79', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 06:46:29";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 06:46:44";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 10:16:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 10:16:44', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 06:46:44";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 06:46:49";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 10:16:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 10:16:49', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:07";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:08', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:32";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:32', '4', 'add', '156.197.9.232', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('8', '', '', '25', '2024-07-10', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '4810',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4835.00','25', '1', '7', 'إضافة مصروف', '5188', '4810', '2024-07-10 11:28:33', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '25', '25', '2024-07-10', '4', '0', '0', '2024-07-10 11:28:33','اضافة اسم مصروف(  )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10648', '151', '25', '','0');
UPDATE accountstree SET name = 'شحن بضاعة', customName = 'شحن بضاعة', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '54500', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '151';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10648', '141', '25', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2197607', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '8', expensesname = '', expensesdetails = '', expensesValue = '25.00', expensesdate = '2024-07-10', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10648', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5188';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:34";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:34', '4', 'sucess', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:36";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:36', '4', 'show', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:40";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 11:28:40', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:53";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:53', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:58:56";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:28:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 11:28:57', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:59:05";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:29:05", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 11:29:05', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 07:59:21";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 11:29:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 11:29:22', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 08:43:45";
UPDATE user SET loginip = "197.32.200.79", lastactivetime = "2024-07-10 12:13:45", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 12:13:46', '3', 'addsellBill', '197.32.200.79', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 08:44:18";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 12:14:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 12:14:18', '4', 'addAndRetuen', '156.197.9.232', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668e4662a06fe
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 11:29:22', '0668e4662a06fe', '1', '0.00', '0', '0', '1', '780', '780', '780', '0', '7', '2024-07-10 12:14:18', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','780','0','','0','0','780','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','اضافة فاتورة مبيعات','17784', '0', '2024-07-10 12:14:18', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '780', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19507;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01804', '17784', '1', '1804', '2', '390.00', '780', '0', '', '2', '2024-07-10 12:14:18', '1804', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','19507-2,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52675;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1804, '2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , 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, '2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , 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 = '4', storedetaildate = '2024-07-10 12:14:18' WHERE storedetailid = '6463';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1804', '7', '2', '1', '17784', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '9', '4', '2024-07-10 12:14:18','0','0');
UPDATE save SET  savecurrentvalue = '5590',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4810.00','780', '0', '7', 'اضافة فاتورة مبيعات', '17784', '5590', '2024-07-10 12:14:18', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , 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, 780, 700, 700
                    , 700, 700, 700, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+780, netSellCostBuyPrice = netSellCostBuyPrice+700
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+700
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+700
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+700
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+700
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668e4662a06fe and sellbillId = 17784 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 08:44:18";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 12:14:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 12:14:19', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 08:44:23";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 12:14:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 12:14:24', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 08:44:28";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 12:14:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 12:14:28', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 10:53:52";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 10:54:11";
UPDATE user SET loginip = "197.192.196.154", lastactivetime = "2024-07-10 14:24:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 14:24:11', '7', '', '197.192.196.154', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 10:54:11";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 10:54:16";
UPDATE user SET loginip = "197.192.196.154", lastactivetime = "2024-07-10 14:24:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 14:24:16', '7', 'addsellBill', '197.192.196.154', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 10:54:34";
UPDATE user SET loginip = "197.192.196.154", lastactivetime = "2024-07-10 14:24:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 14:24:34', '7', 'addsellBill', '197.192.196.154', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 11:56:55";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:26:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 15:26:55', '1', '', '156.210.48.50', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 11:56:56";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 11:59:45";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:29:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:29:45', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:00:02";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:30:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:30:03', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:00:33";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:30:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:30:34', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '9024', productDescription = '', productCatId = '1', productBuyPrice = '270', productSellAllPrice = '210.00', productSellUnitPrice = '260.00', productSellHalfPrice = '220.00', productDate = '2022-06-30', conditions = '0', userId = '1', limitamount = '0', parcode = '01114',type ='0', expireDate = '0' , dailyentryId = '3863',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.76' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1114';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1114, 1,'2024-07-10 15:30:55',1)
                ON DUPLICATE KEY UPDATE productid = 1114, edited = 1, sysdate = '2024-07-10 15:30:55', userid = 1;
UPDATE product SET productName = '9024', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270', productSellUnitPrice = '270', productSellHalfPrice = '270', productDate = '2022-06-30', conditions = '0', userId = '1', limitamount = '0', parcode = '01114',type ='0', expireDate = '0' , dailyentryId = '3863',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '240.00',meanbuyprice_withDiscount = '240' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.76' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1114';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1114, 1,'2024-07-10 15:30:58',1)
                ON DUPLICATE KEY UPDATE productid = 1114, edited = 1, sysdate = '2024-07-10 15:30:58', userid = 1;
UPDATE product SET productName = '9024', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270.00', productSellUnitPrice = '270.00', productSellHalfPrice = '280', productDate = '2022-06-30', conditions = '0', userId = '1', limitamount = '0', parcode = '01114',type ='0', expireDate = '0' , dailyentryId = '3863',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '240.00',meanbuyprice_withDiscount = '240' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.76' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1114';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1114, 1,'2024-07-10 15:31:09',1)
                ON DUPLICATE KEY UPDATE productid = 1114, edited = 1, sysdate = '2024-07-10 15:31:09', userid = 1;
UPDATE product SET productName = '9024', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270.00', productSellUnitPrice = '350', productSellHalfPrice = '280.00', productDate = '2022-06-30', conditions = '0', userId = '1', limitamount = '0', parcode = '01114',type ='0', expireDate = '0' , dailyentryId = '3863',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '240.00',meanbuyprice_withDiscount = '240' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.76' , buypart_precentage = '23.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1114';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1114, 1,'2024-07-10 15:31:37',1)
                ON DUPLICATE KEY UPDATE productid = 1114, edited = 1, sysdate = '2024-07-10 15:31:37', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:01:58";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:31:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:31:59', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'فسكوز 624', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '185.00', productSellUnitPrice = '210.00', productSellHalfPrice = '185.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00428',type ='0', expireDate = '0' , dailyentryId = '428',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '428';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (428, 1,'2024-07-10 15:32:19',1)
                ON DUPLICATE KEY UPDATE productid = 428, edited = 1, sysdate = '2024-07-10 15:32:19', userid = 1;
UPDATE product SET productName = 'فسكوز 624', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00428',type ='0', expireDate = '0' , dailyentryId = '428',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '428';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (428, 1,'2024-07-10 15:32:22',1)
                ON DUPLICATE KEY UPDATE productid = 428, edited = 1, sysdate = '2024-07-10 15:32:22', userid = 1;
UPDATE product SET productName = 'فسكوز 624', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00428',type ='0', expireDate = '0' , dailyentryId = '428',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '428';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (428, 1,'2024-07-10 15:32:26',1)
                ON DUPLICATE KEY UPDATE productid = 428, edited = 1, sysdate = '2024-07-10 15:32:26', userid = 1;
UPDATE product SET productName = 'فسكوز 624', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '310', productSellHalfPrice = '260.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00428',type ='0', expireDate = '0' , dailyentryId = '428',isService = '0',isOptic = '0',lastbuyprice = '170.00',lastbuyprice_withDiscount = '170',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '428';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (428, 1,'2024-07-10 15:32:51',1)
                ON DUPLICATE KEY UPDATE productid = 428, edited = 1, sysdate = '2024-07-10 15:32:51', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:03:10";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:33:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:33:10', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = ' 88 فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '160.00', productSellUnitPrice = '240.00', productSellHalfPrice = '170.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00205',type ='0', expireDate = '0' , dailyentryId = '205',isService = '0',isOptic = '0',lastbuyprice = '135.00',lastbuyprice_withDiscount = '135',meanbuyprice = '198.75',meanbuyprice_withDiscount = '198.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '205';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (205, 1,'2024-07-10 15:33:18',1)
                ON DUPLICATE KEY UPDATE productid = 205, edited = 1, sysdate = '2024-07-10 15:33:18', userid = 1;
UPDATE product SET productName = ' 88 فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00205',type ='0', expireDate = '0' , dailyentryId = '205',isService = '0',isOptic = '0',lastbuyprice = '135.00',lastbuyprice_withDiscount = '135',meanbuyprice = '198.75',meanbuyprice_withDiscount = '198.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '205';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (205, 1,'2024-07-10 15:33:22',1)
                ON DUPLICATE KEY UPDATE productid = 205, edited = 1, sysdate = '2024-07-10 15:33:22', userid = 1;
UPDATE product SET productName = ' 88 فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00205',type ='0', expireDate = '0' , dailyentryId = '205',isService = '0',isOptic = '0',lastbuyprice = '135.00',lastbuyprice_withDiscount = '135',meanbuyprice = '198.75',meanbuyprice_withDiscount = '198.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '205';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (205, 1,'2024-07-10 15:33:26',1)
                ON DUPLICATE KEY UPDATE productid = 205, edited = 1, sysdate = '2024-07-10 15:33:26', userid = 1;
UPDATE product SET productName = ' 88 فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '310', productSellHalfPrice = '260.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00205',type ='0', expireDate = '0' , dailyentryId = '205',isService = '0',isOptic = '0',lastbuyprice = '135.00',lastbuyprice_withDiscount = '135',meanbuyprice = '198.75',meanbuyprice_withDiscount = '198.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '205';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (205, 1,'2024-07-10 15:33:39',1)
                ON DUPLICATE KEY UPDATE productid = 205, edited = 1, sysdate = '2024-07-10 15:33:39', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:03:54";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:33:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:33:54', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:04:09";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:34:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:34:10', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:04:39";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:34:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:34:40', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:04:56";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:34:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:34:56', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'فسكوز 4011', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '220.00', productSellUnitPrice = '270.00', productSellHalfPrice = '230.00', productDate = '2024-03-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01623',type ='0', expireDate = '0' , dailyentryId = '9711',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '235',meanbuyprice_withDiscount = '235' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '22.73',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1623';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1623, 1,'2024-07-10 15:35:10',1)
                ON DUPLICATE KEY UPDATE productid = 1623, edited = 1, sysdate = '2024-07-10 15:35:10', userid = 1;
UPDATE product SET productName = 'فسكوز 4011', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-03-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01623',type ='0', expireDate = '0' , dailyentryId = '9711',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '22.73',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1623';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1623, 1,'2024-07-10 15:35:12',1)
                ON DUPLICATE KEY UPDATE productid = 1623, edited = 1, sysdate = '2024-07-10 15:35:12', userid = 1;
UPDATE product SET productName = 'فسكوز 4011', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-03-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01623',type ='0', expireDate = '0' , dailyentryId = '9711',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '22.73',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1623';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1623, 1,'2024-07-10 15:35:15',1)
                ON DUPLICATE KEY UPDATE productid = 1623, edited = 1, sysdate = '2024-07-10 15:35:15', userid = 1;
UPDATE product SET productName = 'فسكوز 4011', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '310', productSellHalfPrice = '260.00', productDate = '2024-03-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01623',type ='0', expireDate = '0' , dailyentryId = '9711',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '22.73',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1623';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1623, 1,'2024-07-10 15:35:38',1)
                ON DUPLICATE KEY UPDATE productid = 1623, edited = 1, sysdate = '2024-07-10 15:35:38', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:05:45";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:35:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:35:45', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',type ='0', expireDate = '0' , dailyentryId = '10185',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1741';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1741, 1,'2024-07-10 15:35:56',1)
                ON DUPLICATE KEY UPDATE productid = 1741, edited = 1, sysdate = '2024-07-10 15:35:56', userid = 1;
UPDATE product SET productName = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',type ='0', expireDate = '0' , dailyentryId = '10185',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1741';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1741, 1,'2024-07-10 15:35:59',1)
                ON DUPLICATE KEY UPDATE productid = 1741, edited = 1, sysdate = '2024-07-10 15:35:59', userid = 1;
UPDATE product SET productName = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',type ='0', expireDate = '0' , dailyentryId = '10185',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1741';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1741, 1,'2024-07-10 15:36:05',1)
                ON DUPLICATE KEY UPDATE productid = 1741, edited = 1, sysdate = '2024-07-10 15:36:05', userid = 1;
UPDATE product SET productName = '4011فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01741',type ='0', expireDate = '0' , dailyentryId = '10185',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1741';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1741, 1,'2024-07-10 15:36:18',1)
                ON DUPLICATE KEY UPDATE productid = 1741, edited = 1, sysdate = '2024-07-10 15:36:18', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:06:41";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:36:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:36:42', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'فسكوز 4011', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2024-03-12', conditions = '0', userId = '1', limitamount = '0', parcode = '01623',type ='0', expireDate = '0' , dailyentryId = '9711',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , productbuypricereal = '220.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '4.55' , buypart_precentage = '22.73',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1623';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1623, 1,'2024-07-10 15:36:54',1)
                ON DUPLICATE KEY UPDATE productid = 1623, edited = 1, sysdate = '2024-07-10 15:36:54', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:07:10";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:37:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:37:18', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '603 فسكوز جديد', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '280.00', productSellUnitPrice = '320.00', productSellHalfPrice = '290.00', productDate = '2024-04-24', conditions = '0', userId = '1', limitamount = '0', parcode = '01709',type ='0', expireDate = '0' , dailyentryId = '10102',isService = '0',isOptic = '0',lastbuyprice = '280.00',lastbuyprice_withDiscount = '280',meanbuyprice = '265',meanbuyprice_withDiscount = '265' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.57' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1709';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1709, 1,'2024-07-10 15:37:37',1)
                ON DUPLICATE KEY UPDATE productid = 1709, edited = 1, sysdate = '2024-07-10 15:37:37', userid = 1;
UPDATE product SET productName = '603 فسكوز جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-04-24', conditions = '0', userId = '1', limitamount = '0', parcode = '01709',type ='0', expireDate = '0' , dailyentryId = '10102',isService = '0',isOptic = '0',lastbuyprice = '280.00',lastbuyprice_withDiscount = '280',meanbuyprice = '265.00',meanbuyprice_withDiscount = '265' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.57' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1709';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1709, 1,'2024-07-10 15:37:40',1)
                ON DUPLICATE KEY UPDATE productid = 1709, edited = 1, sysdate = '2024-07-10 15:37:40', userid = 1;
UPDATE product SET productName = '603 فسكوز جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-04-24', conditions = '0', userId = '1', limitamount = '0', parcode = '01709',type ='0', expireDate = '0' , dailyentryId = '10102',isService = '0',isOptic = '0',lastbuyprice = '280.00',lastbuyprice_withDiscount = '280',meanbuyprice = '265.00',meanbuyprice_withDiscount = '265' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.57' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1709';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1709, 1,'2024-07-10 15:37:44',1)
                ON DUPLICATE KEY UPDATE productid = 1709, edited = 1, sysdate = '2024-07-10 15:37:44', userid = 1;
UPDATE product SET productName = '603 فسكوز جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2024-04-24', conditions = '0', userId = '1', limitamount = '0', parcode = '01709',type ='0', expireDate = '0' , dailyentryId = '10102',isService = '0',isOptic = '0',lastbuyprice = '280.00',lastbuyprice_withDiscount = '280',meanbuyprice = '265.00',meanbuyprice_withDiscount = '265' , productbuypricereal = '280.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.57' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1709';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1709, 1,'2024-07-10 15:38:28',1)
                ON DUPLICATE KEY UPDATE productid = 1709, edited = 1, sysdate = '2024-07-10 15:38:28', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:08:37";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:38:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:38:38', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:08:49";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:38:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:38:51', '1', '', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:09:32";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:39:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:39:33', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:09:44";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:39:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:39:44', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'ص42', productDescription = '', productCatId = '1', productBuyPrice = '380', productSellAllPrice = '475.00', productSellUnitPrice = '555.00', productSellHalfPrice = '485.00', productDate = '2024-06-26', conditions = '0', userId = '1', limitamount = '0', parcode = '01795',type ='0', expireDate = '0' , dailyentryId = '10555',isService = '0',isOptic = '0',lastbuyprice = '475.00',lastbuyprice_withDiscount = '475',meanbuyprice = '427.5',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '475.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1795';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1795, 1,'2024-07-10 15:40:00',1)
                ON DUPLICATE KEY UPDATE productid = 1795, edited = 1, sysdate = '2024-07-10 15:40:00', userid = 1;
UPDATE product SET productName = 'ص42', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380', productSellUnitPrice = '380', productSellHalfPrice = '380', productDate = '2024-06-26', conditions = '0', userId = '1', limitamount = '0', parcode = '01795',type ='0', expireDate = '0' , dailyentryId = '10555',isService = '0',isOptic = '0',lastbuyprice = '475.00',lastbuyprice_withDiscount = '475',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '475.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1795';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1795, 1,'2024-07-10 15:40:04',1)
                ON DUPLICATE KEY UPDATE productid = 1795, edited = 1, sysdate = '2024-07-10 15:40:04', userid = 1;
UPDATE product SET productName = 'ص42', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '390', productDate = '2024-06-26', conditions = '0', userId = '1', limitamount = '0', parcode = '01795',type ='0', expireDate = '0' , dailyentryId = '10555',isService = '0',isOptic = '0',lastbuyprice = '475.00',lastbuyprice_withDiscount = '475',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '475.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1795';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1795, 1,'2024-07-10 15:40:09',1)
                ON DUPLICATE KEY UPDATE productid = 1795, edited = 1, sysdate = '2024-07-10 15:40:09', userid = 1;
UPDATE product SET productName = 'ص42', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380.00', productSellUnitPrice = '460', productSellHalfPrice = '390.00', productDate = '2024-06-26', conditions = '0', userId = '1', limitamount = '0', parcode = '01795',type ='0', expireDate = '0' , dailyentryId = '10555',isService = '0',isOptic = '0',lastbuyprice = '475.00',lastbuyprice_withDiscount = '475',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '475.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1795';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1795, 1,'2024-07-10 15:40:43',1)
                ON DUPLICATE KEY UPDATE productid = 1795, edited = 1, sysdate = '2024-07-10 15:40:43', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:11:02";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:41:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:41:02', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'فسكوز فراشه 606', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '195.00', productSellUnitPrice = '210.00', productSellHalfPrice = '195.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00441',type ='0', expireDate = '0' , dailyentryId = '441',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '215',meanbuyprice_withDiscount = '215' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '441';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (441, 1,'2024-07-10 15:41:13',1)
                ON DUPLICATE KEY UPDATE productid = 441, edited = 1, sysdate = '2024-07-10 15:41:13', userid = 1;
UPDATE product SET productName = 'فسكوز فراشه 606', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00441',type ='0', expireDate = '0' , dailyentryId = '441',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '215.00',meanbuyprice_withDiscount = '215' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '441';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (441, 1,'2024-07-10 15:41:16',1)
                ON DUPLICATE KEY UPDATE productid = 441, edited = 1, sysdate = '2024-07-10 15:41:16', userid = 1;
UPDATE product SET productName = 'فسكوز فراشه 606', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00441',type ='0', expireDate = '0' , dailyentryId = '441',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '215.00',meanbuyprice_withDiscount = '215' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '441';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (441, 1,'2024-07-10 15:41:19',1)
                ON DUPLICATE KEY UPDATE productid = 441, edited = 1, sysdate = '2024-07-10 15:41:19', userid = 1;
UPDATE product SET productName = 'فسكوز فراشه 606', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00441',type ='0', expireDate = '0' , dailyentryId = '441',isService = '0',isOptic = '0',lastbuyprice = '180.00',lastbuyprice_withDiscount = '180',meanbuyprice = '215.00',meanbuyprice_withDiscount = '215' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '441';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (441, 1,'2024-07-10 15:41:32',1)
                ON DUPLICATE KEY UPDATE productid = 441, edited = 1, sysdate = '2024-07-10 15:41:32', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:11:45";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:41:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:41:46', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '6006', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00945',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '945';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (945, 1,'2024-07-10 15:42:09',1)
                ON DUPLICATE KEY UPDATE productid = 945, edited = 1, sysdate = '2024-07-10 15:42:09', userid = 1;
UPDATE product SET productName = '6006', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00945',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '945';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (945, 1,'2024-07-10 15:42:14',1)
                ON DUPLICATE KEY UPDATE productid = 945, edited = 1, sysdate = '2024-07-10 15:42:14', userid = 1;
UPDATE product SET productName = '6006', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00945',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '945';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (945, 1,'2024-07-10 15:42:16',1)
                ON DUPLICATE KEY UPDATE productid = 945, edited = 1, sysdate = '2024-07-10 15:42:16', userid = 1;
UPDATE product SET productName = '6006', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2022-04-11', conditions = '0', userId = '1', limitamount = '0', parcode = '00945',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '945';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (945, 1,'2024-07-10 15:42:41',1)
                ON DUPLICATE KEY UPDATE productid = 945, edited = 1, sysdate = '2024-07-10 15:42:41', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:12:55";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:42:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:42:56', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '10151',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1717';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1717, 1,'2024-07-10 15:43:05',1)
                ON DUPLICATE KEY UPDATE productid = 1717, edited = 1, sysdate = '2024-07-10 15:43:05', userid = 1;
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '10151',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1717';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1717, 1,'2024-07-10 15:43:08',1)
                ON DUPLICATE KEY UPDATE productid = 1717, edited = 1, sysdate = '2024-07-10 15:43:08', userid = 1;
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '10151',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1717';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1717, 1,'2024-07-10 15:43:11',1)
                ON DUPLICATE KEY UPDATE productid = 1717, edited = 1, sysdate = '2024-07-10 15:43:11', userid = 1;
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '10151',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1717';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1717, 1,'2024-07-10 15:43:20',1)
                ON DUPLICATE KEY UPDATE productid = 1717, edited = 1, sysdate = '2024-07-10 15:43:20', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:13:29";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:43:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:43:30', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '6008', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00943',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '943';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (943, 1,'2024-07-10 15:43:39',1)
                ON DUPLICATE KEY UPDATE productid = 943, edited = 1, sysdate = '2024-07-10 15:43:39', userid = 1;
UPDATE product SET productName = '6008', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00943',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '943';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (943, 1,'2024-07-10 15:43:41',1)
                ON DUPLICATE KEY UPDATE productid = 943, edited = 1, sysdate = '2024-07-10 15:43:41', userid = 1;
UPDATE product SET productName = '6008', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00943',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '943';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (943, 1,'2024-07-10 15:43:45',1)
                ON DUPLICATE KEY UPDATE productid = 943, edited = 1, sysdate = '2024-07-10 15:43:45', userid = 1;
UPDATE product SET productName = '6008', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2022-04-10', conditions = '0', userId = '1', limitamount = '0', parcode = '00943',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '943';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (943, 1,'2024-07-10 15:43:54',1)
                ON DUPLICATE KEY UPDATE productid = 943, edited = 1, sysdate = '2024-07-10 15:43:54', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:14:02";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:44:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:44:03', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '6015', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '200.00', productSellUnitPrice = '240.00', productSellHalfPrice = '210.00', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00957',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '957';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (957, 1,'2024-07-10 15:44:21',1)
                ON DUPLICATE KEY UPDATE productid = 957, edited = 1, sysdate = '2024-07-10 15:44:21', userid = 1;
UPDATE product SET productName = '6015', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00957',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '957';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (957, 1,'2024-07-10 15:44:24',1)
                ON DUPLICATE KEY UPDATE productid = 957, edited = 1, sysdate = '2024-07-10 15:44:24', userid = 1;
UPDATE product SET productName = '6015', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00957',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '957';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (957, 1,'2024-07-10 15:44:43',1)
                ON DUPLICATE KEY UPDATE productid = 957, edited = 1, sysdate = '2024-07-10 15:44:43', userid = 1;
UPDATE product SET productName = '6015', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2022-04-12', conditions = '0', userId = '1', limitamount = '0', parcode = '00957',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '275.00',meanbuyprice_withDiscount = '275' , productbuypricereal = '200.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '5.00' , buypart_precentage = '20.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '957';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (957, 1,'2024-07-10 15:44:47',1)
                ON DUPLICATE KEY UPDATE productid = 957, edited = 1, sysdate = '2024-07-10 15:44:47', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:15:34";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:45:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:45:35', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',type ='0', expireDate = '0' , dailyentryId = '10184',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1740';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1740, 1,'2024-07-10 15:45:55',1)
                ON DUPLICATE KEY UPDATE productid = 1740, edited = 1, sysdate = '2024-07-10 15:45:55', userid = 1;
UPDATE product SET productName = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',type ='0', expireDate = '0' , dailyentryId = '10184',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1740';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1740, 1,'2024-07-10 15:45:58',1)
                ON DUPLICATE KEY UPDATE productid = 1740, edited = 1, sysdate = '2024-07-10 15:45:58', userid = 1;
UPDATE product SET productName = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',type ='0', expireDate = '0' , dailyentryId = '10184',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1740';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1740, 1,'2024-07-10 15:47:40',1)
                ON DUPLICATE KEY UPDATE productid = 1740, edited = 1, sysdate = '2024-07-10 15:47:40', userid = 1;
UPDATE product SET productName = '6010فسكوز', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-05-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01740',type ='0', expireDate = '0' , dailyentryId = '10184',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '255.00',meanbuyprice_withDiscount = '255' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1740';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1740, 1,'2024-07-10 15:53:22',1)
                ON DUPLICATE KEY UPDATE productid = 1740, edited = 1, sysdate = '2024-07-10 15:53:22', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:23:31";
UPDATE user SET loginip = "156.210.48.50", lastactivetime = "2024-07-10 15:53:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 15:53:31', '1', 'show', '156.210.48.50', '', 'DESKTOP');
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '250', productSellAllPrice = '270.00', productSellUnitPrice = '310.00', productSellHalfPrice = '280.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '10153',isService = '0',isOptic = '0',lastbuyprice = '270.00',lastbuyprice_withDiscount = '270',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.70' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1719';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1719, 1,'2024-07-10 15:53:38',1)
                ON DUPLICATE KEY UPDATE productid = 1719, edited = 1, sysdate = '2024-07-10 15:53:38', userid = 1;
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '10153',isService = '0',isOptic = '0',lastbuyprice = '270.00',lastbuyprice_withDiscount = '270',meanbuyprice = '260.00',meanbuyprice_withDiscount = '260' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.70' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1719';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1719, 1,'2024-07-10 15:53:41',1)
                ON DUPLICATE KEY UPDATE productid = 1719, edited = 1, sysdate = '2024-07-10 15:53:41', userid = 1;
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '260', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '10153',isService = '0',isOptic = '0',lastbuyprice = '270.00',lastbuyprice_withDiscount = '270',meanbuyprice = '260.00',meanbuyprice_withDiscount = '260' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.70' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1719';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1719, 1,'2024-07-10 15:53:44',1)
                ON DUPLICATE KEY UPDATE productid = 1719, edited = 1, sysdate = '2024-07-10 15:53:44', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:40:40";

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668e50f4d3524
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 12:14:28', '0668e50f4d3524', '1', '0.00', '0', '0', '1', '410', '410', '410', '0', '7', '2024-07-10 16:10:41', '', null, '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','410','0','','0','0','410','0','0','0','0','0','0','0','0','');
ROLLBACK;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668e50f4d3524 and sellbillId = 0 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:40:41";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:41:34";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:11:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 16:11:34', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:41:34";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:41:37";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:11:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:11:37', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:41:41";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:11:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 16:11:41', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:41:50";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:11:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:11:50', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:42:55";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:12:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:12:55', '4', 'addAndRetuen', '156.197.9.232', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668e8896973b2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 16:11:50', '0668e8896973b2', '1', '0.00', '0', '0', '1', '410', '410', '410', '0', '7', '2024-07-10 16:12:55', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','410','0','','0','0','410','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','اضافة فاتورة مبيعات','17785', '0', '2024-07-10 16:12:55', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '410', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18839;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('500','01640', '17785', '1', '1640', '1', '410.00', '410', '0', '', '2', '2024-07-10 16:12:55', '1640', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','18839-1,');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1322.50, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1322.50
                where sellbilldetailid = 52676;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1640, '2024-07-10', 410, 400, 500
                    , 1322.5, 500, 1322.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1322.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1322.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 (7, '2024-07-10', 410, 400, 500
                    , 1322.5, 500, 1322.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1322.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1322.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 = '4', storedetaildate = '2024-07-10 16:12:55' WHERE storedetailid = '5978';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1640', '7', '1', '1', '17785', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '4', '2024-07-10 16:12:55','0','0');
UPDATE save SET  savecurrentvalue = '6000',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5590.00','410', '0', '7', 'اضافة فاتورة مبيعات', '17785', '6000', '2024-07-10 16:12:55', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 410, 400, 500
                    , 1322.5, 500, 1322.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1322.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1322.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 410, 400, 500
                    , 1322.5, 500, 1322.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1322.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1322.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, 410, 400, 500
                    , 1322.5, 500, 1322.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+410, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1322.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1322.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668e8896973b2 and sellbillId = 17785 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:42:56";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:12:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:12:56', '4', 'addsellBill', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:42:58";
UPDATE user SET loginip = "156.197.9.232", lastactivetime = "2024-07-10 16:12:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 16:12:58', '4', '', '156.197.9.232', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:58:49";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:59:17";
UPDATE user SET loginip = "197.192.238.193", lastactivetime = "2024-07-10 16:29:18", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 16:29:18', '7', '', '197.192.238.193', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 12:59:18";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:00:07";
UPDATE user SET loginip = "197.192.238.193", lastactivetime = "2024-07-10 16:30:07", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:30:07', '7', 'addsellBill', '197.192.238.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:26:25";
UPDATE user SET loginip = "197.192.238.193", lastactivetime = "2024-07-10 16:56:25", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 16:56:25', '7', 'addsellBill', '197.192.238.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:47:00";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 17:17:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 17:17:00', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:48:27";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 17:18:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 17:18:28', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:49:21";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:55:49";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 17:25:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 17:25:49', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:55:50";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 13:57:44";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 17:27:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 17:27:45', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '250.00', productSellUnitPrice = '330', productSellHalfPrice = '260.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '10153',isService = '0',isOptic = '0',lastbuyprice = '270.00',lastbuyprice_withDiscount = '270',meanbuyprice = '260.00',meanbuyprice_withDiscount = '260' , productbuypricereal = '270.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '3.70' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1719';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1719, 1,'2024-07-10 17:35:51',1)
                ON DUPLICATE KEY UPDATE productid = 1719, edited = 1, sysdate = '2024-07-10 17:35:51', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:13:28";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 17:43:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 17:43:29', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:44:21";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:14:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 18:14:21', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:44:22";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:44:26";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:14:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:14:26', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:44:26";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:14:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:14:26', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:47:52";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:17:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 18:17:52', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:48:55";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:18:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 18:18:55', '1', 'add', '156.210.110.165', '', '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 (' 3شامية','','1','330','360', '410','370', '2024-07-10', '0', '1', '0', '', '0', '0', '0', '0', '0', '330','330','330','330','330','0','9.09','12.12','24.24','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = ' 3شامية', productDescription = '', productCatId = '1', productBuyPrice = '330', productSellAllPrice = '360', productSellUnitPrice = '410', productSellHalfPrice = '370', productDate = '2024-07-10', conditions = '0', userId = '1', limitamount = '0', parcode = '01807',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330' , buypricereal_precentage = '0' , buytotal_precentage = '9.09' , buyhalf_precentage = '12.12' , buypart_precentage = '24.24',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1807';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1807', '1', '2024-07-10', '1', '0','0180701','360','370','410','330');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1807', '1', '36', '1', '2024-07-10');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '1', '36', '0', '1807', 'إضافة منتج', 'productController.php', '0', '36', '1', '2024-07-10','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1807, 1,'2024-07-10 18:18:55',1)
                ON DUPLICATE KEY UPDATE productid = 1807, edited = 1, sysdate = '2024-07-10 18:18:55', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '11880', '11880', '2024-07-10', '1', '0', '0', '2024-07-10 18:18:55','إضافة منتج  3شامية الكمية 36','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10649', '19', '11880', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '20658700.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10649', '7', '11880', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '21417051.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = ' 3شامية', productDescription = '', productCatId = '1', productBuyPrice = '330.00', productSellAllPrice = '360.00', productSellUnitPrice = '410.00', productSellHalfPrice = '370.00', productDate = '2024-07-10', conditions = '0', userId = '1', limitamount = '0', parcode = '01807',type ='0', expireDate = '0' , dailyentryId = '10649',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330' , buypricereal_precentage = '0' , buytotal_precentage = '9.09' , buyhalf_precentage = '12.12' , buypart_precentage = '24.24',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1807';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:48:57";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:18:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 18:18:57', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:49:04";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:19:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:19:04', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:50:38";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:20:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:20:39', '1', 'add', '156.210.110.165', '', '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(2161,1,7,1807,18,'2024-07-10',1,0, '' ,0,0,0,0,0,'2024-07-10 18:20:39',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6467';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1807, 0, 0
                    , 330.00, -18, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyprice = 330.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-07-10*330.00," WHERE transferproductid = 8962;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '1', '18', '1', '8962', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '18', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1807', '7', '18', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 7, 1807, 0, 0
                    , 330.00, 18, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '7', '18', '0', '8962', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '18', '1', '2024-07-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1741', '12', '2024-07-10', '1', '0','2161',null,null,'2024-07-10 18:20:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-12', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6254';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1741, 0, 0
                    , 260.00, -12, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-07-10*260.00," WHERE transferproductid = 8963;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '1', '12', '1', '8963', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-12', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6268';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 7, 1741, 0, 0
                    , 260.00, 12, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '7', '12', '0', '8963', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '14', '1', '2024-07-10','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', '441', '12', '2024-07-10', '1', '0','2161',null,null,'2024-07-10 18:20:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-12', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '441';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 441, 0, 0
                    , 180.00, -12, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyprice = 180.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-07-10*180.00," WHERE transferproductid = 8964;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('441', '1', '12', '1', '8964', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-12', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '5166';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 7, 441, 0, 0
                    , 180.00, 12, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('441', '7', '12', '0', '8964', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2024-07-10','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', '945', '20', '2024-07-10', '1', '0','2161',null,null,'2024-07-10 18:20:39',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '2999';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 945, 0, 0
                    , 200.00, -20, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyprice = 200.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-07-10*200.00," WHERE transferproductid = 8965;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('945', '1', '20', '1', '8965', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '0', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '3345';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 7, 945, 0, 0
                    , 200.00, 20, 0, 0, 1, '2024-07-10 18:20:39')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:20:39' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('945', '7', '20', '0', '8965', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '20', '1', '2024-07-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:50:39";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:20:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:20:39', '1', 'editshow', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:52:31";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:22:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:22:31', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:56:37";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:26:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:26:37', '1', 'add', '156.210.110.165', '', '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(2162,1,8,1807,18,'2024-07-10',1,0, '' ,0,0,0,0,0,'2024-07-10 18:26:37',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6467';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1807, 0, 0
                    , 330.00, -18, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 330.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-07-10*330.00," WHERE transferproductid = 8966;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '1', '18', '1', '8966', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1807', '8', '18', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1807, 0, 0
                    , 330.00, 18, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1807', '8', '18', '0', '8966', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '18', '1', '2024-07-10','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', '146', '16', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-16', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '146';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 146, 0, 0
                    , 180.00, -16, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 180.00,
                        buyQuantity =buyQuantity+-16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2024-07-10*180.00," WHERE transferproductid = 8967;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('146', '1', '16', '1', '8967', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-16', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '3997';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 146, 0, 0
                    , 180.00, 16, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('146', '8', '16', '0', '8967', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '16', '1', '2024-07-10','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', '1114', '12', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-12', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '3970';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1114, 0, 0
                    , 210.00, -12, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-07-10*210.00," WHERE transferproductid = 8968;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1114', '1', '12', '1', '8968', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-12', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '4063';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1114, 0, 0
                    , 210.00, 12, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1114', '8', '12', '0', '8968', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '12', '1', '2024-07-10','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', '293', '20', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-20', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '293';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 293, 0, 0
                    , 160.00, -20, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 160.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-07-10*160.00," WHERE transferproductid = 8969;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('293', '1', '20', '1', '8969', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-20', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('293', '8', '20', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 293, 0, 0
                    , 160.00, 20, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('293', '8', '20', '0', '8969', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-07-10','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', '205', '26', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-26', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '205';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 205, 0, 0
                    , 135.00, -26, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 135.00,
                        buyQuantity =buyQuantity+-26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2024-07-10*135.00," WHERE transferproductid = 8970;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('205', '1', '26', '1', '8970', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-26', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('205', '8', '26', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 205, 0, 0
                    , 135.00, 26, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('205', '8', '26', '0', '8970', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '26', '1', '2024-07-10','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', '1741', '19', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-31', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6254';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1741, 0, 0
                    , 260.00, -19, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-07-10*260.00," WHERE transferproductid = 8971;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '1', '19', '1', '8971', 'تحويل منتجات من المخزن', 'storemovementController.php', '-12.00', '-31', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1741', '8', '19', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1741, 0, 0
                    , 260.00, 19, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1741', '8', '19', '0', '8971', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '19', '1', '2024-07-10','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', '1709', '15', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6179';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1709, 0, 0
                    , 280.00, -15, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 280.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-07-10*280.00," WHERE transferproductid = 8972;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1709', '1', '15', '1', '8972', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6193';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1709, 0, 0
                    , 280.00, 15, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1709', '8', '15', '0', '8972', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '8.00', '23', '1', '2024-07-10','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', '1770', '19', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6359';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1770, 0, 0
                    , 350.00, -19, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-07-10*350.00," WHERE transferproductid = 8973;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '19', '1', '8973', 'تحويل منتجات من المخزن', 'storemovementController.php', '41.00', '22', '1', '2024-07-10','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6361';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1770, 0, 0
                    , 350.00, 19, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '19', '0', '8973', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '7.00', '26', '1', '2024-07-10','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', '1795', '20', '2024-07-10', '1', '0','2162',null,null,'2024-07-10 18:26:37',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '208', userid = '1', storedetaildate = '2024-07-10' WHERE storedetailid = '6440';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 1, 1795, 0, 0
                    , 475.00, -20, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyprice = 475.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-07-10*475.00," WHERE transferproductid = 8974;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '1', '20', '1', '8974', 'تحويل منتجات من المخزن', 'storemovementController.php', '228.00', '208', '1', '2024-07-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1795', '8', '20', '1', '2024-07-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-07-10', 8, 1795, 0, 0
                    , 475.00, 20, 0, 0, 1, '2024-07-10 18:26:37')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-07-10 18:26:37' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1795', '8', '20', '0', '8974', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-07-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:56:38";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:26:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-07-10 18:26:38', '1', 'editshow', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:58:36";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:58:52";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 18:28:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 18:28:52', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:58:53";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:58:57";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 18:28:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 18:28:57', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 14:59:06";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 18:29:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 18:29:07', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:15:15";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:45:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:45:15', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:15:25";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:45:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:45:25', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:11";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-10 18:46:11', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:23";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-10 18:46:23', '1', 'add', '156.210.110.165', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '6', '-1', '0', '3880.00', '65', '3945', '', '0', '2024-07-10 18:46:23', '1', 'settlementsaveController.php');
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('-1', '', '65', '1', ' خصم معالجة عجز  / ', '596', '-65', '2024-07-10', '1', 'supplierPayedDeptController.php', '', '0','6', '0','1','1','65','1');
UPDATE supplier SET  suppliercurrentDebt = '-65', userid = '1', supplierdate = '2024-07-10'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '65.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '596', supplierdebtchangeafter = '-65.00', supplierdebtchangedate = '2024-07-10 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '6',currencyId='1',conversionFactor='1',payedInCurrency='65',saveConversionFactor='1' WHERE supplierdebtchangeid = '971';
UPDATE save SET  savecurrentvalue = '3945',  userid = '1' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3880.00','65', '0', '6', 'تسوية خزنة بالإضافة', '-1', '3945', '2024-07-10 18:46:23', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '29594' WHERE savedailyid = '29594';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '65', '65', '2024-07-10', '1', '0', '0', '2024-07-10 18:46:23','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10650', '140', '65', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2070887', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10650', '27', '65', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-136160', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:24";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-10 18:46:24', '1', 'sucess', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:26";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-10 18:46:26', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:36";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:46:36', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:16:47";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:46:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:46:47', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:17:10";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:47:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:47:11', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:17:21";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:47:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:47:21', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:18:24";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:48:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:48:25', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:21:19";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:51:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:51:19', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:21:34";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:51:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:51:35', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:23:31";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:53:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 18:53:31', '4', '', '156.210.110.165', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:23:31";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:23:34";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:53:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 18:53:34', '4', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:27:00";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:57:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 18:57:00', '4', 'add', '156.210.110.165', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'مصروف احمد توكل', 'مصروف احمد توكل', '50', '2024-07-10', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5950',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('6000.00','50', '1', '7', 'إضافة مصروف', '5189', '5950', '2024-07-10 18:57:00', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '50', '50', '2024-07-10', '4', '0', '0', '2024-07-10 18:57:00','اضافة اسم مصروف( مصروف احمد توكل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10651', '160', '50', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4563745', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10651', '141', '50', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2197657', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'مصروف احمد توكل', expensesdetails = 'مصروف احمد توكل', expensesValue = '50.00', expensesdate = '2024-07-10', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10651', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5189';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:27:01";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:57:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 18:57:01', '4', 'sucess', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:27:03";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:57:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 18:57:03', '4', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:27:15";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 18:57:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 18:57:15', '4', '', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:51:00";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:51:07";
UPDATE user SET loginip = "197.32.248.214", lastactivetime = "2024-07-10 19:21:08", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 19:21:08', '3', '', '197.32.248.214', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:51:08";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 15:51:33";
UPDATE user SET loginip = "197.32.248.214", lastactivetime = "2024-07-10 19:21:33", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 19:21:33', '3', 'addsellBill', '197.32.248.214', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:03:48";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:33:48", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:33:48', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:03:49";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:33:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:33:49', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:03:54";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:33:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:33:54', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:03:58";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:33:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:33:58', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:06:44";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:36:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:36:44', '7', 'addAndRetuen', '197.192.232.193', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668ec60672bc2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 20:33:58', '0668ec60672bc2', '1', '0.00', '0', '0', '1', '1270', '1270', '1270', '0', '5', '2024-07-10 20:36:44', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1270','0','','0','0','1270','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','اضافة فاتورة مبيعات','17786', '0', '2024-07-10 20:36:44', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1270', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 17497;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('320','01402', '17786', '1', '1402', '2', '350.00', '700', '0', '', '2', '2024-07-10 20:36:44', '1402', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','17497-2,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 52677;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1402, '2024-07-10', 700, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 700, 640, 640
                    , 640, 640, 640, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2024-07-10 20:36:44' WHERE storedetailid = '5188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1402', '5', '2', '1', '17786', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '7', '7', '2024-07-10 20:36:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18295;
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 ('270','01719', '17786', '1', '1719', '1', '260.00', '260', '0', '', '2', '2024-07-10 20:36:44', '1719', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','18295-1,');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 260.00
                where sellbilldetailid = 52678;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1719, '2024-07-10', 260, 250, 270
                    , 260, 270, 260, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 260, 250, 270
                    , 260, 270, 260, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '7', storedetaildate = '2024-07-10 20:36:44' WHERE storedetailid = '6220';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1719', '5', '1', '1', '17786', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '7', '2024-07-10 20:36:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17495;
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 ('300','01626', '17786', '1', '1626', '1', '310.00', '310', '0', '', '2', '2024-07-10 20:36:44', '1626', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','17495-1,');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 52679;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1626, '2024-07-10', 310, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 310, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '7', storedetaildate = '2024-07-10 20:36:44' WHERE storedetailid = '5919';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1626', '5', '1', '1', '17786', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24.00', '23', '7', '2024-07-10 20:36:44','0','0');
UPDATE save SET  savecurrentvalue = '6375',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5105.00','1270', '0', '5', 'اضافة فاتورة مبيعات', '17786', '6375', '2024-07-10 20:36:44', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 1270, 1190, 1210
                    , 1200, 1210, 1200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1270, sellCostBuyPrice =sellCostBuyPrice+1190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 1270, 1190, 1210
                    , 1200, 1210, 1200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1270, sellCostBuyPrice =sellCostBuyPrice+1190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1270, 1190, 1210
                    , 1200, 1210, 1200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1270, netSellCostBuyPrice = netSellCostBuyPrice+1190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668ec60672bc2 and sellbillId = 17786 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:06:45";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:36:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:36:45', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:07:22";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:37:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:37:22', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:07:46";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:37:46", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:37:46', '7', 'add', '197.192.232.193', '', '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 =26342
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(92,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '640' , clientdate = '2024-07-10 20:37:46', userid = '7' WHERE clientid = '92';
UPDATE client SET  inUse = 0 where clientid = 92;
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 ('92','1030.00','390','1','ايصال تحصيل (( قبض من عميل ))','26342', '640', '2024-07-10 20:37:22', '7', 'clientPayedDeptController.php', '   ', '390', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '6765',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('6375.00','390', '0', '5', 'ايصال تحصيل (( قبض من عميل ))', '26342', '6765', '2024-07-10 20:37:46', '7',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '390', '390', '2024-07-10', '7', '0', '0', '2024-07-10 20:37:46','اضافة ايصال سداد للعميل ام محمود اسكندرية','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10652', '139', '390', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3305753', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10652', '167', '390', '','0');
UPDATE accountstree SET name = 'ام محمود اسكندرية', customName = 'ام محمود اسكندرية', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '5', mydate = '2021-12-09', itemtype2 = '1', theValue = '-2345', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '167';
UPDATE clientdebtchange SET clientid = '92', clientdebtchangebefore = '1030.00', clientdebtchangeamount = '390.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '26342', clientdebtchangeafter = '640.00', clientdebtchangedate = '2024-07-10 20:37:22', userid = '7', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '390.00',discount='', reciptid=null, dailyentryid = '10652',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '26342';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:07:47";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:37:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:37:47', '7', 'sucess', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:07:49";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:37:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:37:49', '7', 'show', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:07:55";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:37:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:37:55', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:08:39";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:38:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:38:39', '7', 'addAndRetuen', '197.192.232.193', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668ec6f3d622b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 20:37:55', '0668ec6f3d622b', '1', '0.00', '0', '0', '1', '2070', '2070', '2070', '0', '5', '2024-07-10 20:38:39', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','2070','0','','0','0','2070','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','اضافة فاتورة مبيعات','17787', '0', '2024-07-10 20:38:39', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2070', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19279;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01779', '17787', '1', '1779', '2', '390.00', '780', '0', '', '2', '2024-07-10 20:38:39', '1779', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19279-2,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 52680;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1779, '2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 780, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , 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 = '2024-07-10 20:38:39' WHERE storedetailid = '6428';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1779', '5', '2', '1', '17787', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '11', '7', '2024-07-10 20:38:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19265;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17787', '1', '1577', '2', '460.00', '920', '0', '', '2', '2024-07-10 20:38:39', '1577', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19265-2,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52681;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-10', 920, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 920, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '7', storedetaildate = '2024-07-10 20:38:39' WHERE storedetailid = '5697';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '2', '1', '17787', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '12', '7', '2024-07-10 20:38:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19235;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('360','01785', '17787', '1', '1785', '1', '370.00', '370', '0', '', '2', '2024-07-10 20:38:39', '1785', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19235-1,');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 52682;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-07-10', 370, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-07-10', 370, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '26', userid = '7', storedetaildate = '2024-07-10 20:38:39' WHERE storedetailid = '6419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '5', '1', '1', '17787', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27.00', '26', '7', '2024-07-10 20:38:39','0','0');
UPDATE save SET  savecurrentvalue = '8835',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('6765.00','2070', '0', '5', 'اضافة فاتورة مبيعات', '17787', '8835', '2024-07-10 20:38:39', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 2070, 1960, 1960
                    , 1960, 1960, 1960, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2070, sellCostBuyPrice =sellCostBuyPrice+1960
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1960, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1960
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1960, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1960
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 2070, 1960, 1960
                    , 1960, 1960, 1960, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2070, sellCostBuyPrice =sellCostBuyPrice+1960
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1960, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1960
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1960, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1960
                            , 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, 2070, 1960, 1960
                    , 1960, 1960, 1960, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2070, netSellCostBuyPrice = netSellCostBuyPrice+1960
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1960
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1960
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1960
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1960
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668ec6f3d622b and sellbillId = 17787 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:08:40";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:38:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:38:40', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:08:43";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:38:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:38:44', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:02";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:39:02', '7', 'add', '197.192.232.193', '', '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 =26344
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(89,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-07-10 20:39:02', userid = '7' WHERE clientid = '89';
UPDATE client SET  inUse = 0 where clientid = 89;
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 ('89','75.00','75','1','ايصال تحصيل (( قبض من عميل ))','26344', '0', '2024-07-10 20:38:44', '7', 'clientPayedDeptController.php', '   ', '75', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '8910',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8835.00','75', '0', '5', 'ايصال تحصيل (( قبض من عميل ))', '26344', '8910', '2024-07-10 20:39:02', '7',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '75', '75', '2024-07-10', '7', '0', '0', '2024-07-10 20:39:02','اضافة ايصال سداد للعميل ام محمد نوح','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10653', '139', '75', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3305678', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10653', '164', '75', '','0');
UPDATE accountstree SET name = 'ام محمد نوح', customName = 'ام محمد نوح', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '5', mydate = '2021-12-07', itemtype2 = '1', theValue = '-45935', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '164';
UPDATE clientdebtchange SET clientid = '89', clientdebtchangebefore = '75.00', clientdebtchangeamount = '75.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '26344', clientdebtchangeafter = '0.00', clientdebtchangedate = '2024-07-10 20:38:44', userid = '7', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '75.00',discount='', reciptid=null, dailyentryid = '10653',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '26344';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:02";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:39:03', '7', 'sucess', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:05";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-07-10 20:39:05', '7', 'show', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:12";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:39:12', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:29";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:39:30', '7', 'showDetail', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:35";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:35", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:39:35', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:56";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:39:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:39:56', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09:58";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:39:58", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 20:39:58', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:09: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 < "2024-07-10 17:10:01";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:40:01", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:40:01', '8', 'addsellBill', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:10:08";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 20:40:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:40:08', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:10:55";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:40:55", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:40:55', '8', 'addAndRetuen', '197.63.192.40', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668ec771ebaec
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 20:40:01', '0668ec771ebaec', '1', '0.00', '0', '0', '1', '1615', '1615', '1615', '0', '6', '2024-07-10 20:40:56', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1615','0','','0','0','1615','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17788', '0', '2024-07-10 20:40:56', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1615', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 18315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17788', '1', '1581', '2', '530', '1060', '0', '', '1', '2024-07-10 20:40:56', '1581', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','18315-2,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52683;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-07-10', 1060, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-10', 1060, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '39', userid = '8', storedetaildate = '2024-07-10 20:40:56' WHERE storedetailid = '5629';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '2', '1', '17788', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41.00', '39', '8', '2024-07-10 20:40:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18991;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01760', '17788', '1', '1760', '1', '555', '555', '0', '', '1', '2024-07-10 20:40:56', '1760', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','18991-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 52684;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-07-10', 555, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-10', 555, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+555, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '8', storedetaildate = '2024-07-10 20:40:56' WHERE storedetailid = '6334';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '6', '1', '1', '17788', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '8', '2024-07-10 20:40:56','0','0');
UPDATE save SET  savecurrentvalue = '5560',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3945.00','1615', '0', '6', 'اضافة فاتورة مبيعات', '17788', '5560', '2024-07-10 20:40:56', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 1615, 1375, 1375
                    , 1375, 1375, 1375, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1615, sellCostBuyPrice =sellCostBuyPrice+1375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1375
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 1615, 1375, 1375
                    , 1375, 1375, 1375, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1615, sellCostBuyPrice =sellCostBuyPrice+1375
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1375, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1375, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1375
                            , 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, 1615, 1375, 1375
                    , 1375, 1375, 1375, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1615, netSellCostBuyPrice = netSellCostBuyPrice+1375
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1375
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1375
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1375
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1375
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668ec771ebaec and sellbillId = 17788 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:10:56";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:40:56", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:40:56', '8', 'addsellBill', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:11:37";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:41:37", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:41:37', '8', 'addAndRetuen', '197.63.192.40', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0668ec7a8b7651
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-07-10 20:40:56', '0668ec7a8b7651', '1', '0.00', '0', '0', '1', '1505', '1505', '1505', '0', '6', '2024-07-10 20:41:38', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1505','0','','0','0','1505','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17789', '0', '2024-07-10 20:41:38', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1505', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17789', '1', '1581', '1', '450', '450', '0', '', '0', '2024-07-10 20:41:38', '1581', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','18315-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52685;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '38', userid = '8', storedetaildate = '2024-07-10 20:41:38' WHERE storedetailid = '5629';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '1', '1', '17789', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39.00', '38', '8', '2024-07-10 20:41:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19205;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17789', '1', '1577', '1', '450', '450', '0', '', '0', '2024-07-10 20:41:38', '1577', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','19205-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52686;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '8', storedetaildate = '2024-07-10 20:41:38' WHERE storedetailid = '5638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '6', '1', '1', '17789', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24.00', '23', '8', '2024-07-10 20:41:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19203;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01729', '17789', '1', '1729', '1', '450', '450', '0', '', '0', '2024-07-10 20:41:38', '1729', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','19203-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 52687;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1729, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-07-10', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '8', storedetaildate = '2024-07-10 20:41:38' WHERE storedetailid = '6333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '6', '1', '1', '17789', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '8', '2024-07-10 20:41:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 3296;
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 ('150','00283', '17789', '1', '283', '1', '155', '155', '0', '', '0', '2024-07-10 20:41:38', '283', '0.00', '0', '6','0','','','0','0','0','0','0','0','0','0','','3296-1,');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
                where sellbilldetailid = 52688;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (283, '2024-07-10', 155, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, 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 (6, '2024-07-10', 155, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, 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 = '18', userid = '8', storedetaildate = '2024-07-10 20:41:38' WHERE storedetailid = '2231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('283', '6', '1', '1', '17789', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19.00', '18', '8', '2024-07-10 20:41:38','0','0');
UPDATE save SET  savecurrentvalue = '7065',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5560.00','1505', '0', '6', 'اضافة فاتورة مبيعات', '17789', '7065', '2024-07-10 20:41:38', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-07-10', 1505, 1500, 1500
                    , 1500, 1500, 1500, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1505, sellCostBuyPrice =sellCostBuyPrice+1500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-07-10', 1505, 1500, 1500
                    , 1500, 1500, 1500, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1505, sellCostBuyPrice =sellCostBuyPrice+1500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1500
                            , 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, 1505, 1500, 1500
                    , 1500, 1500, 1500, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1505, netSellCostBuyPrice = netSellCostBuyPrice+1500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1500
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1500
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0668ec7a8b7651 and sellbillId = 17789 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:11:38";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:41:38", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:41:38', '8', 'addsellBill', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:30";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:30", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:42:30', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:34";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:34", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-07-10 20:42:34', '8', 'editprint', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:36";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:36", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:42:36', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:39";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:39", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:42:39', '8', 'showDetail', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:44";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:44", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:42:44', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:49";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:49", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:42:49', '8', 'showDetail', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:55";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:55", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 20:42:55', '8', 'addsellBill', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:12:59";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 20:42:59", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 20:42:59', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE userid = 8;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:52:36";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:52:58";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:22:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 21:22:58', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:52:58";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:53:12";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:23:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 21:23:12', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:10";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:15";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:15", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 21:29:15', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:16";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:19";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:19", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 21:29:19', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:21";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:21", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:21', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:33";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:33", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:33', '8', 'add', '197.63.192.40', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جهاد', '', '1500', '2024-07-10', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5565',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7065.00','1500', '1', '6', 'إضافة مصروف', '5190', '5565', '2024-07-10 21:29:34', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1500', '1500', '2024-07-10', '8', '0', '0', '2024-07-10 21:29:34','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10654', '160', '1500', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4565245', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10654', '140', '1500', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2072387', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جهاد', expensesdetails = '', expensesValue = '1500.00', expensesdate = '2024-07-10', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10654', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5190';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:34";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:34", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:34', '8', 'sucess', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:36";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:36", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:36', '8', 'show', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:36";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:36", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:36', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:43";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:43", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:43', '8', 'add', '197.63.192.40', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'فطار', '', '20', '2024-07-10', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5545',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5565.00','20', '1', '6', 'إضافة مصروف', '5191', '5545', '2024-07-10 21:29:43', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-07-10', '8', '0', '0', '2024-07-10 21:29:43','اضافة اسم مصروف( فطار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10655', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4565265', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10655', '140', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2072407', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'فطار', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-07-10', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10655', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5191';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:44";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:44", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-07-10 21:29:44', '8', 'sucess', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 17:59:45";
UPDATE user SET loginip = "197.63.192.40", lastactivetime = "2024-07-10 21:29:45", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 21:29:45', '8', '', '197.63.192.40', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:01:51";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:31:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 21:31:51', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:02:10";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:32:10", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 21:32:10', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:07:40";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:37:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 21:37:40', '7', '', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:07:56";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:37:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-07-10 21:37:56', '7', 'showDetail', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:24:55";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 21:54:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 21:54:55', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 18:30:13";
UPDATE user SET loginip = "197.192.232.193", lastactivetime = "2024-07-10 22:00:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 22:00:13', '7', 'addsellBill', '197.192.232.193', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 19:02:20";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 22:32:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-07-10 22:32:21', '1', '', '156.210.110.165', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 19:02: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 userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 19:40:57";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 23:10:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-07-10 23:10:58', '1', 'addsellBill', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 19:47:12";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 23:17:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 23:17:12', '1', 'show', '156.210.110.165', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-07-10 19:47:34";
UPDATE user SET loginip = "156.210.110.165", lastactivetime = "2024-07-10 23:17:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-07-10 23:17:34', '1', 'show', '156.210.110.165', '', 'DESKTOP');
