UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 06:19:38";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 06:19:48";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 09:49:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 09:49:48', '4', '', '197.35.236.144', '', '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-02-27',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-02-27',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-02-27 06:19:51";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 06:19:54";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 09:49:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 09:49:54', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:35:46";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:05:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:05:46', '4', 'addAndRetuen', '197.35.236.144', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 065dd94223a0ac
-- ----------------------------------------------------------------------------------------------------

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-02-27 09:49:54', '065dd94223a0ac', '1', '0.00', '0', '0', '1', '2170', '2170', '2170', '0', '7', '2024-02-27 11:05:46', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','2170','0','','0','0','2170','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','اضافة فاتورة مبيعات','15534', '0', '2024-02-27 11:05:46', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2170', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17041;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01588', '15534', '1', '1588', '1', '420', '420', '0', '', '2', '2024-02-27 11:05:46', '1588', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17041-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 46092;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1588, '2024-02-27', 420, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-02-27', 420, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '4', storedetaildate = '2024-02-27 11:05:46' WHERE storedetailid = '5757';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1588', '7', '1', '1', '15534', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37.00', '36', '4', '2024-02-27 11:05:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17017;
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', '15534', '1', '1581', '1', '460', '460', '0', '', '2', '2024-02-27 11:05:46', '1581', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17017-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 46093;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-02-27', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-02-27', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '45', userid = '4', storedetaildate = '2024-02-27 11:05:46' WHERE storedetailid = '5745';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '7', '1', '1', '15534', 'اضافة فاتورة مبيعات', 'sellbillController.php', '46.00', '45', '4', '2024-02-27 11:05:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17027;
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','01564', '15534', '1', '1564', '1', '390', '390', '0', '', '2', '2024-02-27 11:05:46', '1564', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17027-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 46094;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1564, '2024-02-27', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-02-27', 390, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '29', userid = '4', storedetaildate = '2024-02-27 11:05:46' WHERE storedetailid = '5750';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1564', '7', '1', '1', '15534', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30.00', '29', '4', '2024-02-27 11:05:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17029;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('370','01563', '15534', '1', '1563', '1', '410', '410', '0', '', '2', '2024-02-27 11:05:46', '1563', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17029-1,');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 46095;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1563, '2024-02-27', 410, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-02-27', 410, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '29', userid = '4', storedetaildate = '2024-02-27 11:05:46' WHERE storedetailid = '5751';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1563', '7', '1', '1', '15534', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30.00', '29', '4', '2024-02-27 11:05:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17039;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('480','01585', '15534', '1', '1585', '1', '490', '490', '0', '', '2', '2024-02-27 11:05:46', '1585', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17039-1,');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
                where sellbilldetailid = 46096;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1585, '2024-02-27', 490, 480, 480
                    , 480, 480, 480, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , 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-02-27', 490, 480, 480
                    , 480, 480, 480, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '41', userid = '4', storedetaildate = '2024-02-27 11:05:46' WHERE storedetailid = '5756';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1585', '7', '1', '1', '15534', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42.00', '41', '4', '2024-02-27 11:05:46','0','0');
UPDATE save SET  savecurrentvalue = '2270',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('100.00','2170', '0', '7', 'اضافة فاتورة مبيعات', '15534', '2270', '2024-02-27 11:05:46', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-02-27', 2170, 2060, 2060
                    , 2060, 2060, 2060, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2170, sellCostBuyPrice =sellCostBuyPrice+2060
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2060
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2060
                            , 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-02-27', 2170, 2060, 2060
                    , 2060, 2060, 2060, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2170, sellCostBuyPrice =sellCostBuyPrice+2060
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2060
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2060
                            , 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, 2170, 2060, 2060
                    , 2060, 2060, 2060, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2170, netSellCostBuyPrice = netSellCostBuyPrice+2060
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2060
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2060
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2060
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2060
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 065dd94223a0ac and sellbillId = 15534 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:35:47";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:05:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:05:47', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:35:49";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:05:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 11:05:49', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:35:51";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:05:51", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:05:51', '4', 'showDetail', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:40:56";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:10:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:10:56', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:58:25";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:28:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:28:25', '4', 'addAndRetuen', '197.35.236.144', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 065dda7209fb67
-- ----------------------------------------------------------------------------------------------------

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-02-27 11:10:56', '065dda7209fb67', '1', '0.00', '0', '40', '1', '1240', '1200', '1200', '0', '7', '2024-02-27 11:28:25', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1200','0','','0','0','1200','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','اضافة فاتورة مبيعات','15535', '0', '2024-02-27 11:28:25', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1200', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 17273;
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 ('390','01512', '15535', '1', '1512', '2', '410', '820', '0', '', '0', '2024-02-27 11:28:25', '1512', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','17273-2,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 46097;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1512, '2024-02-27', 793.54838709677, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+793.54838709677, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , 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-02-27', 793.54838709677, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+793.54838709677, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '4', storedetaildate = '2024-02-27 11:28:25' WHERE storedetailid = '5531';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1512', '7', '2', '1', '15535', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4.00', '2', '4', '2024-02-27 11:28:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17275;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('400','01507', '15535', '1', '1507', '1', '420', '420', '0', '', '0', '2024-02-27 11:28:25', '1507', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','17275-1,');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where sellbilldetailid = 46098;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1507, '2024-02-27', 406.45161290323, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+406.45161290323, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , 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-02-27', 406.45161290323, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+406.45161290323, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '4', storedetaildate = '2024-02-27 11:28:25' WHERE storedetailid = '5517';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1507', '7', '1', '1', '15535', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '4', '2024-02-27 11:28:25','0','0');
UPDATE save SET  savecurrentvalue = '3470',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2270.00','1200', '0', '7', 'اضافة فاتورة مبيعات', '15535', '3470', '2024-02-27 11:28:25', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-02-27', 1200, 1180, 1180
                    , 1180, 1180, 1180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+1180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1180
                            , 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-02-27', 1200, 1180, 1180
                    , 1180, 1180, 1180, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+1180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1180
                            , 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, 1200, 1180, 1180
                    , 1180, 1180, 1180, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1200, netSellCostBuyPrice = netSellCostBuyPrice+1180
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1180
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1180
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1180
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1180
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 065dda7209fb67 and sellbillId = 15535 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:58:26";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:28:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:28:26', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:58:28";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:28:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 11:28:28', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 07:58:33";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 11:28:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 11:28:33', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 08:39:01";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 12:09:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 12:09:01', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 08:39:01";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 12:09:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 12:09:01', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 08:40:58";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 12:10:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 12:10:58', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:48: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-02-27 09:48:15";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 13:18:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 13:18:15', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:48: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-02-27 09:48:17";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 13:18:17", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 13:18:17', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:48:23";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 13:18:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 13:18:24', '4', 'showDetail', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:48:30";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 13:18:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 13:18:30', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:58:15";
UPDATE user SET loginip = "197.32.190.75", lastactivetime = "2024-02-27 13:28:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 13:28:15', '3', '', '197.32.190.75', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 09:58: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-02-27 09:58:26";
UPDATE user SET loginip = "197.32.190.75", lastactivetime = "2024-02-27 13:28:26", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 13:28:26', '3', 'addsellBill', '197.32.190.75', '', '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-02-27 10:44:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:14:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 14:14:18', '1', '', '156.210.43.215', '', '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-02-27 10:44:19";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:44:24";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:14:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:14:24', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:44:33";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:14:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:14:33', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:45:33";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:15:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:15:33', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:45:44";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:15:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:15:44', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:46:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:16:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:16:18', '1', 'add', '156.210.43.215', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5541';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1515', '1', '22', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '22', '1', '2024-02-27','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:46:20";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:16:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:16:20', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:46:39";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:16:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:16:39', '1', 'add', '156.210.43.215', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5542';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1516', '1', '20', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '20', '1', '2024-02-27','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:46:41";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:16:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:16:41', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:46:59";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:16:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:16:59', '1', 'add', '156.210.43.215', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5543';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1517', '1', '20', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '20', '1', '2024-02-27','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:47:01";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:17:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:17:01', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:47:24";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:17:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:17:24', '1', 'add', '156.210.43.215', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5544';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1518', '1', '18', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '18', '1', '2024-02-27','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:47:26";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:17:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-02-27 14:17:26', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:47:28";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:17:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:17:28', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:48:19";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:18:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:18:19', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:48:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:18:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:18:49', '1', 'add', '156.210.43.215', '', '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(1798,1,8,1516,20,'2024-02-27',1,0, '' ,0,0,0,0,0,'2024-02-27 14:18:49',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5542';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1516, 0, 0
                    , 375.00, -20, 0, 0, 1, '2024-02-27 14:18:49')
                ON DUPLICATE KEY UPDATE buyprice = 375.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:18:49' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-02-27*375.00," WHERE transferproductid = 7996;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1516', '1', '20', '1', '7996', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '0', '1', '2024-02-27','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5545';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 8, 1516, 0, 0
                    , 375.00, 20, 0, 0, 1, '2024-02-27 14:18:49')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:18:49' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1516', '8', '20', '0', '7996', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '20', '1', '2024-02-27','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', '1518', '18', '2024-02-27', '1', '0','1798',null,null,'2024-02-27 14:18:49',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5544';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1518, 0, 0
                    , 385.00, -18, 0, 0, 1, '2024-02-27 14:18:49')
                ON DUPLICATE KEY UPDATE buyprice = 385.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:18:49' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-02-27*385.00," WHERE transferproductid = 7997;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1518', '1', '18', '1', '7997', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-02-27','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5546';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 8, 1518, 0, 0
                    , 385.00, 18, 0, 0, 1, '2024-02-27 14:18:49')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:18:49' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1518', '8', '18', '0', '7997', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '18', '1', '2024-02-27','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:48:50";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:18:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:18:50', '1', 'editshow', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:48:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:18:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:18:57', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:49:55";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:19:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:19:56', '1', 'add', '156.210.43.215', '', '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(1799,1,7,1515,22,'2024-02-27',1,0, '' ,0,0,0,0,0,'2024-02-27 14:19:56',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5541';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1515, 0, 0
                    , 375.00, -22, 0, 0, 1, '2024-02-27 14:19:56')
                ON DUPLICATE KEY UPDATE buyprice = 375.00,
                        buyQuantity =buyQuantity+-22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:19:56' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-02-27*375.00," WHERE transferproductid = 7998;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1515', '1', '22', '1', '7998', 'تحويل منتجات من المخزن', 'storemovementController.php', '22.00', '0', '1', '2024-02-27','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5547';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 7, 1515, 0, 0
                    , 375.00, 22, 0, 0, 1, '2024-02-27 14:19:56')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:19:56' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1515', '7', '22', '0', '7998', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '22', '1', '2024-02-27','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', '1517', '20', '2024-02-27', '1', '0','1799',null,null,'2024-02-27 14:19:56',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5543';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1517, 0, 0
                    , 380.00, -20, 0, 0, 1, '2024-02-27 14:19:56')
                ON DUPLICATE KEY UPDATE buyprice = 380.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:19:56' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-02-27*380.00," WHERE transferproductid = 7999;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1517', '1', '20', '1', '7999', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '0', '1', '2024-02-27','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5548';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 7, 1517, 0, 0
                    , 380.00, 20, 0, 0, 1, '2024-02-27 14:19:56')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 14:19:56' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1517', '7', '20', '0', '7999', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '20', '1', '2024-02-27','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:49:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:19:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 14:19:56', '1', 'editshow', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:50:58";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 14:20:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:20:58', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:56:24";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:26:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 14:26:24', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:56:25";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:56:28";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:26:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:26:28', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 10:56:58";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:26:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:26:58', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:05:28";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:35:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 14:35:28', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:05:42";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:35:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:35:42', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:06:09";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:36:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-02-27 14:36:09', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:06:12";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:36:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 14:36:12', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:07:23";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:37:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 14:37:23', '4', 'add', '197.35.236.144', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جمال بوظه', '', '600', '2024-02-27', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2870',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3470.00','600', '1', '7', 'إضافة مصروف', '4629', '2870', '2024-02-27 14:37:23', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '600', '600', '2024-02-27', '4', '0', '0', '2024-02-27 14:37:23','اضافة اسم مصروف( جمال بوظه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9551', '160', '600', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-3191723', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9551', '141', '600', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1759157', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جمال بوظه', expensesdetails = '', expensesValue = '600.00', expensesdate = '2024-02-27', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '9551', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4629';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:07:23";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:37:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 14:37:24', '4', 'sucess', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:07:25";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:37:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 14:37:25', '4', 'show', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:07:41";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:37:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:37:41', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:08:12";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:38:12", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:38:12', '4', 'showDetail', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:08:41";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:38:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:38:41', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:09:31";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:39:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:39:31', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:16:07";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:46:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:46:07', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:16:10";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:46:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:46:10', '4', 'showDetail', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:18:21";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:48:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:48:21', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:18:24";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:48:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:48:24', '4', 'showDetail', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:28:13";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:58:13", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 14:58:13', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:28:15";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 14:58:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 14:58:15', '4', 'addsellBill', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:55:56";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:25:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-02-27 15:25:56', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:02";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:02", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 15:26:02', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:43";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 15:26:43', '4', 'add', '197.35.236.144', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'مصروف احمد يومين', '', '40', '2024-02-27', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '2830',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('2870.00','40', '1', '7', 'إضافة مصروف', '4630', '2830', '2024-02-27 15:26:43', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '40', '40', '2024-02-27', '4', '0', '0', '2024-02-27 15:26:43','اضافة اسم مصروف( مصروف احمد يومين )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9552', '160', '40', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-3191763', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9552', '141', '40', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1759197', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'مصروف احمد يومين', expensesdetails = '', expensesValue = '40.00', expensesdate = '2024-02-27', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '9552', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4630';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:43";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 15:26:43', '4', 'sucess', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:45";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 15:26:45', '4', 'show', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:48";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 15:26:48', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:56:49";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:26:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 15:26:49', '4', '', '197.35.236.144', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 11:57:26";
UPDATE user SET loginip = "197.35.236.144", lastactivetime = "2024-02-27 15:27:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 15:27:27', '4', 'addsellBill', '197.35.236.144', '', '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-02-27 12:45:17";
UPDATE user SET loginip = "197.63.211.63", lastactivetime = "2024-02-27 16:15:17", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 16:15:17', '8', '', '197.63.211.63', '', '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-02-27 12:45:17";
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-02-27 12:45:40";
UPDATE user SET loginip = "197.63.211.63", lastactivetime = "2024-02-27 16:15:40", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 16:15:40', '8', 'addsellBill', '197.63.211.63', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:32:08";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:32:23";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:32:27";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:32:59";
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-02-27 13:33:44";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 17:03:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 17:03:44', '7', '', '197.192.233.22', '', '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-02-27 13:33:45";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:54:30";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:54:38";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:24:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 17:24:38', '4', '', '156.197.63.219', '', '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-02-27 13:54:39";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:54:41";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:24:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 17:24:41', '4', '', '156.197.63.219', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:56:54";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:26:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 17:26:54', '4', 'showDetail', '156.197.63.219', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:57:16";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:27:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 17:27:16', '4', '', '156.197.63.219', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:57:19";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:27:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 17:27:19', '4', 'showDetail', '156.197.63.219', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 13:57:30";
UPDATE user SET loginip = "156.197.63.219", lastactivetime = "2024-02-27 17:27:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 17:27:30', '4', '', '156.197.63.219', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:10:44";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 17:40:44", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 17:40:44', '7', 'addsellBill', '197.192.233.22', '', '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-02-27 14:11:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:41:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 17:41:18', '1', '', '156.210.43.215', '', '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-02-27 14:11: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-02-27 14:11:44";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:41:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 17:41:45', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:11:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:41:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 17:41:57', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:11:59";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:41:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 17:41:59', '1', 'edit', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:12:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:42:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 17:42:57', '1', 'update', '156.210.43.215', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 1563;
UPDATE productunit SET unitid = '1', productid = '1563', productnumber = '1.00', productunitdate = '2024-02-27', userid = '1', conditions = '0',proUnitParcode='0156301',proUnitSellAllPrice='400',proUnitSellHalfPrice='410',proUnitSellUnitPrice ='500',proUnitBuyPrice='370' WHERE productunitid = '1563';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1563, 1,'2024-02-27 17:42:57',1)
                ON DUPLICATE KEY UPDATE productid = 1563, edited = 1, sysdate = '2024-02-27 17:42:57', userid = 1;
UPDATE product SET productName = 'الخياش 345', productDescription = '', productCatId = '1', productBuyPrice = '370', productSellAllPrice = '400', productSellUnitPrice = '450', productSellHalfPrice = '410', productDate = '2024-02-23', conditions = '0', userId = '1', limitamount = '0', parcode = '01563',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370.00',lastbuyprice_withDiscount = '370',meanbuyprice = '370.00',meanbuyprice_withDiscount = '370' , productbuypricereal = '370' , buypricereal_precentage = '0' , buytotal_precentage = '8.11' , buyhalf_precentage = '10.81' , buypart_precentage = '21.62',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1563';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:13:00";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:43:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 17:43:00', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:13:02";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:43:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 17:43:02', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:13:06";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:43:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 17:43:06', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:13:11";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:43:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 17:43:12', '1', 'editorder', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:13:13";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 17:43:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 17:43:13', '1', 'editorder', '156.210.43.215', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 14:28:00";
UPDATE user SET loginip = "197.32.222.109", lastactivetime = "2024-02-27 17:58:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 17:58:00', '3', '', '197.32.222.109', '', '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-02-27 14:28:00";
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-02-27 14:28:21";
UPDATE user SET loginip = "197.32.222.109", lastactivetime = "2024-02-27 17:58:21", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 17:58:21', '3', 'addsellBill', '197.32.222.109', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE userid = 8;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:16: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-02-27 16:16:34";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 19:46:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 19:46:34', '1', '', '156.210.43.215', '', '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-02-27 16:16: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-02-27 16:16:41";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 19:46:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 19:46:41', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:17:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 19:47:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 19:47:56', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:18:13";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 19:48:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 19:48:13', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:18:23";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 19:48:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 19:48:23', '1', 'show', '156.210.43.215', '', '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-02-27 16:27:57";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 19:57:57", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 19:57:57', '8', '', '154.183.8.159', '', '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-02-27 16:27:57";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:28:07";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 19:58:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 19:58:07', '8', 'addsellBill', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:41:32";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:11:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:11:33', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:41:39";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:11:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:11:39', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:47:40";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:17:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:17:40', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:48:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:18:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:18:57', '1', '', '156.210.43.215', '', '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-02-27 16:48: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-02-27 16:51:07";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:21:07', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:08";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:08', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:09";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:09', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:09";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:10', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:10";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:10', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:11";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:11', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:11";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:11', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:12";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:12', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:13";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:13', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:13";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:13', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:14";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:14', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:15";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:15', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:15";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:15', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:16";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:16', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:16";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:17', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:17";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:17', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:18', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:18', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:19";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:19', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:20";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:20', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:21";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:21', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:21";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:21', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:22";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:22', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:23";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:23', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:23";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:24', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:24";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:24', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:25";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:25', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:26";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:26', '1', 'show', '156.210.43.215', '', '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-02-27 16:51:45";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:21:45', '1', '', '156.210.43.215', '', '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-02-27 16:51:45";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:46";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:46', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:47";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:47', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:47";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:47', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:48";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:48', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:49', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:49', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:50";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:50', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:51";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:51', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:51";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:51', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:52";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:52', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:52";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:53', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:53";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:53', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:54";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:54', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:54";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:55', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:55";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:55', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:56', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:57', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:51:59";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:21:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:21:59', '1', 'show', '156.210.43.215', '', '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-02-27 16:52:28";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:22:28', '1', '', '156.210.43.215', '', '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-02-27 16:52: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-02-27 16:52:29";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:29', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:30";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:30', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:31";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:31', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:31";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:31', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:32";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:32', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:33";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:33', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:33";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:33', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:34";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:34', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:35";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:35', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:35";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:35', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:36";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:36', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:36";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:36', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:37";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:37', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:38";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:38', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:38";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:38', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:39";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:40', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:40";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:40', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:41";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:41', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:42";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:42', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:42";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:42', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:43";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:43', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:43";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:44', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:44";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:45', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:45";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:45', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:45";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:45', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:46";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:46', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:46";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:46', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:47";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:22:47', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:48";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:48', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:49', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:49', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:50";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:50', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:51";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:51', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:52";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:52', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:52";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:52', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:53";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:53', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:54";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:54', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:54";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:54', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:55";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:55', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:56', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:56', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:57', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:58";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:58', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:58";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:58', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:52:59";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:22:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:22:59', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:00";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:00', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:00";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:01', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:01";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:01', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:02";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:02', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:02";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:02', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:03";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:03', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:04";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:04', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:05";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:05', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:05";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:05', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:06";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:06', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:07";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:07', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:07";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:07', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:17";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:23:17', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:18', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:19";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:19', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:19";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:19', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:20";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:20', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:20";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:20', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:21";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:21', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:22";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:22', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:22";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:22', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:23";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:23', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:23";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:23', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:24";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:25', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:25";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:25', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:26";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:26', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:26";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:26', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:27";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:27', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:27";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:28', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:28";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:28', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:29";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:29', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:29";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:29', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:30";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:30', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:30";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:30', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:31";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:31', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:32";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:32', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:32";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-02-27 20:23:32', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:46";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:23:46', '1', '', '156.210.43.215', '', '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-02-27 16:53:46";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:51";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:23:51', '1', 'addsellBill', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:53:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:23:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:23:56', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 16:54:04";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:24:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-02-27 20:24:04', '1', 'show', '156.210.43.215', '', '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-02-27 17:12:04";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:42:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:42:04', '1', '', '156.210.43.215', '', '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-02-27 17:12:05";
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-02-27 17:12:34";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:42:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 20:42:34', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:18:09";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:48:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 20:48:09', '1', 'add', '156.210.43.215', '', '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 ('مستر مروان 910','','1','370','400', '450','410', '2024-02-27', '0', '1', '0', '', '0', '0', '0', '0', '0', '370','370','370','370','370','0','8.11','10.81','21.62','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'مستر مروان 910', productDescription = '', productCatId = '1', productBuyPrice = '370', productSellAllPrice = '400', productSellUnitPrice = '450', productSellHalfPrice = '410', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01589',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '370',meanbuyprice = '370',meanbuyprice_withDiscount = '370' , productbuypricereal = '370' , buypricereal_precentage = '0' , buytotal_precentage = '8.11' , buyhalf_precentage = '10.81' , buypart_precentage = '21.62',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1589';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1589', '1', '2024-02-27', '1', '0','0158901','400','410','450','370');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1589', '1', '63', '1', '2024-02-27');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1589', '1', '63', '0', '1589', 'إضافة منتج', 'productController.php', '0', '63', '1', '2024-02-27','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1589, 1,'2024-02-27 20:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 1589, edited = 1, sysdate = '2024-02-27 20:48:09', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '23310', '23310', '2024-02-27', '1', '0', '0', '2024-02-27 20:48:09','إضافة منتج مستر مروان 910 الكمية 63','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9553', '19', '23310', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '17201135.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9553', '7', '23310', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '17959416.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'مستر مروان 910', productDescription = '', productCatId = '1', productBuyPrice = '370.00', productSellAllPrice = '400.00', productSellUnitPrice = '450.00', productSellHalfPrice = '410.00', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01589',type ='0', expireDate = '0' , dailyentryId = '9553',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '370',meanbuyprice = '370',meanbuyprice_withDiscount = '370' , productbuypricereal = '370' , buypricereal_precentage = '0' , buytotal_precentage = '8.11' , buyhalf_precentage = '10.81' , buypart_precentage = '21.62',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1589';
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 ('مستر مروان 912','','1','385','415', '465','425', '2024-02-27', '0', '1', '0', '', '0', '0', '0', '0', '0', '385','385','385','385','385','0','7.79','10.39','20.78','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'مستر مروان 912', productDescription = '', productCatId = '1', productBuyPrice = '385', productSellAllPrice = '415', productSellUnitPrice = '465', productSellHalfPrice = '425', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01590',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '385',lastbuyprice_withDiscount = '385',meanbuyprice = '385',meanbuyprice_withDiscount = '385' , productbuypricereal = '385' , buypricereal_precentage = '0' , buytotal_precentage = '7.79' , buyhalf_precentage = '10.39' , buypart_precentage = '20.78',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1590';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1590', '1', '2024-02-27', '1', '0','0159001','415','425','465','385');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1590', '1', '56', '1', '2024-02-27');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1590', '1', '56', '0', '1590', 'إضافة منتج', 'productController.php', '0', '56', '1', '2024-02-27','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1590, 1,'2024-02-27 20:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 1590, edited = 1, sysdate = '2024-02-27 20:48:09', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '21560', '21560', '2024-02-27', '1', '0', '0', '2024-02-27 20:48:09','إضافة منتج مستر مروان 912 الكمية 56','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9554', '19', '21560', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '17222695.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9554', '7', '21560', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '17980976.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'مستر مروان 912', productDescription = '', productCatId = '1', productBuyPrice = '385.00', productSellAllPrice = '415.00', productSellUnitPrice = '465.00', productSellHalfPrice = '425.00', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01590',type ='0', expireDate = '0' , dailyentryId = '9554',isService = '0',isOptic = '0',lastbuyprice = '385',lastbuyprice_withDiscount = '385',meanbuyprice = '385',meanbuyprice_withDiscount = '385' , productbuypricereal = '385' , buypricereal_precentage = '0' , buytotal_precentage = '7.79' , buyhalf_precentage = '10.39' , buypart_precentage = '20.78',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1590';
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 ('مستر مروان 903','','1','390','420', '470','430', '2024-02-27', '0', '1', '0', '', '0', '0', '0', '0', '0', '390','390','390','390','390','0','7.69','10.26','20.51','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'مستر مروان 903', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '420', productSellUnitPrice = '470', productSellHalfPrice = '430', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01591',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '390',lastbuyprice_withDiscount = '390',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '390' , buypricereal_precentage = '0' , buytotal_precentage = '7.69' , buyhalf_precentage = '10.26' , buypart_precentage = '20.51',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1591';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1591', '1', '2024-02-27', '1', '0','0159101','420','430','470','390');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1591', '1', '64', '1', '2024-02-27');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1591', '1', '64', '0', '1591', 'إضافة منتج', 'productController.php', '0', '64', '1', '2024-02-27','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1591, 1,'2024-02-27 20:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 1591, edited = 1, sysdate = '2024-02-27 20:48:09', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '24960', '24960', '2024-02-27', '1', '0', '0', '2024-02-27 20:48:09','إضافة منتج مستر مروان 903 الكمية 64','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9555', '19', '24960', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '17247655.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9555', '7', '24960', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '18005936.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'مستر مروان 903', productDescription = '', productCatId = '1', productBuyPrice = '390.00', productSellAllPrice = '420.00', productSellUnitPrice = '470.00', productSellHalfPrice = '430.00', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01591',type ='0', expireDate = '0' , dailyentryId = '9555',isService = '0',isOptic = '0',lastbuyprice = '390',lastbuyprice_withDiscount = '390',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '390' , buypricereal_precentage = '0' , buytotal_precentage = '7.69' , buyhalf_precentage = '10.26' , buypart_precentage = '20.51',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1591';
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 ('مستر مروان 907','','1','365','395', '445','405', '2024-02-27', '0', '1', '0', '', '0', '0', '0', '0', '0', '365','365','365','365','365','0','8.22','10.96','21.92','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'مستر مروان 907', productDescription = '', productCatId = '1', productBuyPrice = '365', productSellAllPrice = '395', productSellUnitPrice = '445', productSellHalfPrice = '405', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01592',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '365',lastbuyprice_withDiscount = '365',meanbuyprice = '365',meanbuyprice_withDiscount = '365' , productbuypricereal = '365' , buypricereal_precentage = '0' , buytotal_precentage = '8.22' , buyhalf_precentage = '10.96' , buypart_precentage = '21.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1592';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1592', '1', '2024-02-27', '1', '0','0159201','395','405','445','365');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1592', '1', '64', '1', '2024-02-27');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1592', '1', '64', '0', '1592', 'إضافة منتج', 'productController.php', '0', '64', '1', '2024-02-27','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1592, 1,'2024-02-27 20:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 1592, edited = 1, sysdate = '2024-02-27 20:48:09', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '23360', '23360', '2024-02-27', '1', '0', '0', '2024-02-27 20:48:09','إضافة منتج مستر مروان 907 الكمية 64','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9556', '19', '23360', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '17271015.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9556', '7', '23360', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '18029296.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'مستر مروان 907', productDescription = '', productCatId = '1', productBuyPrice = '365.00', productSellAllPrice = '395.00', productSellUnitPrice = '445.00', productSellHalfPrice = '405.00', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01592',type ='0', expireDate = '0' , dailyentryId = '9556',isService = '0',isOptic = '0',lastbuyprice = '365',lastbuyprice_withDiscount = '365',meanbuyprice = '365',meanbuyprice_withDiscount = '365' , productbuypricereal = '365' , buypricereal_precentage = '0' , buytotal_precentage = '8.22' , buyhalf_precentage = '10.96' , buypart_precentage = '21.92',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1592';
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 ('مستر مروان 911','','1','390','420', '470','430', '2024-02-27', '0', '1', '0', '', '0', '0', '0', '0', '0', '390','390','390','390','390','0','7.69','10.26','20.51','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'مستر مروان 911', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '420', productSellUnitPrice = '470', productSellHalfPrice = '430', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01593',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '390',lastbuyprice_withDiscount = '390',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '390' , buypricereal_precentage = '0' , buytotal_precentage = '7.69' , buyhalf_precentage = '10.26' , buypart_precentage = '20.51',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1593';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1593', '1', '2024-02-27', '1', '0','0159301','420','430','470','390');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1593', '1', '60', '1', '2024-02-27');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '1', '60', '0', '1593', 'إضافة منتج', 'productController.php', '0', '60', '1', '2024-02-27','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1593, 1,'2024-02-27 20:48:09',1)
                ON DUPLICATE KEY UPDATE productid = 1593, edited = 1, sysdate = '2024-02-27 20:48:09', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '23400', '23400', '2024-02-27', '1', '0', '0', '2024-02-27 20:48:09','إضافة منتج مستر مروان 911 الكمية 60','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9557', '19', '23400', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '17294415.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9557', '7', '23400', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '18052696.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'مستر مروان 911', productDescription = '', productCatId = '1', productBuyPrice = '390.00', productSellAllPrice = '420.00', productSellUnitPrice = '470.00', productSellHalfPrice = '430.00', productDate = '2024-02-27', conditions = '0', userId = '1', limitamount = '0', parcode = '01593',type ='0', expireDate = '0' , dailyentryId = '9557',isService = '0',isOptic = '0',lastbuyprice = '390',lastbuyprice_withDiscount = '390',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '390' , buypricereal_precentage = '0' , buytotal_precentage = '7.69' , buyhalf_precentage = '10.26' , buypart_precentage = '20.51',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1593';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:18:11";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:48:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-02-27 20:48:11', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:18:45";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:48:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:48:45', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:19:01";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:49:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:49:01', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:19:22";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:49:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:49:22', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:19:35";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:49:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:49:35', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:19:48";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:49:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:49:48', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:20:18";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 20:50:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2024-02-27 20:50:18', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:28:09";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 20:58:09", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 20:58:09', '8', '', '154.183.8.159', '', '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-02-27 17:28:10";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:28:12";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 20:58:12", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 20:58:12', '8', 'addsellBill', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:18";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:18", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 21:02:18', '8', 'addAndRetuen', '154.183.8.159', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 065de30c48595f
-- ----------------------------------------------------------------------------------------------------

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-02-27 20:58:12', '065de30c48595f', '1', '0.00', '0', '0', '1', '920', '920', '920', '0', '6', '2024-02-27 21:02:18', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','920','0','','0','0','920','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','اضافة فاتورة مبيعات','15536', '0', '2024-02-27 21:02:18', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '920', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 16677;
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 ('390','01512', '15536', '1', '1512', '2', '460', '920', '0', '', '1', '2024-02-27 21:02:18', '1512', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','16677-2,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 46099;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1512, '2024-02-27', 920, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , 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-02-27', 920, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '8', storedetaildate = '2024-02-27 21:02:18' WHERE storedetailid = '5529';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1512', '6', '2', '1', '15536', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19.00', '17', '8', '2024-02-27 21:02:18','0','0');
UPDATE save SET  savecurrentvalue = '5760',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4840.00','920', '0', '6', 'اضافة فاتورة مبيعات', '15536', '5760', '2024-02-27 21:02:18', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-02-27', 920, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-02-27', 920, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+920, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 920, 780, 780
                    , 780, 780, 780, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+920, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+780
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+780
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 065de30c48595f and sellbillId = 15536 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:18";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:18", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 21:02:19', '8', 'addsellBill', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:21";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:21", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 21:02:21', '8', '', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:27";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:27", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:27', '8', '', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:34";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:35", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:35', '8', 'add', '154.183.8.159', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'فطار', '', '20', '2024-02-27', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5740',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5760.00','20', '1', '6', 'إضافة مصروف', '4631', '5740', '2024-02-27 21:02:35', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-02-27', '8', '0', '0', '2024-02-27 21:02:35','اضافة اسم مصروف( فطار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9558', '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 = '-3191783', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9558', '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 = '-1518092', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'فطار', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-02-27', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '9558', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4631';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:35";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:35", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:35', '8', 'sucess', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:37";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:37", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:38', '8', 'show', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:43";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:43", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:43', '8', '', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:53";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:53", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:53', '8', 'add', '154.183.8.159', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'جهاد', '', '1000', '2024-02-27', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '4740',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5740.00','1000', '1', '6', 'إضافة مصروف', '4632', '4740', '2024-02-27 21:02:53', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1000', '1000', '2024-02-27', '8', '0', '0', '2024-02-27 21:02:53','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9559', '145', '1000', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '487770', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9559', '140', '1000', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1519092', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '2', expensesname = 'جهاد', expensesdetails = '', expensesValue = '1000.00', expensesdate = '2024-02-27', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '9559', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4632';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:54";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:54", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:54', '8', 'sucess', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:56";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:56", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 21:02:56', '8', 'show', '154.183.8.159', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 17:32:56";
UPDATE user SET loginip = "154.183.8.159", lastactivetime = "2024-02-27 21:02:56", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 21:02:56', '8', '', '154.183.8.159', '', '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-02-27 18:02:28";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:32:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 21:32:28', '1', '', '156.210.43.215', '', '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-02-27 18:02: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-02-27 18:19:24";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:49:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 21:49:24', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:19:35";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:49:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 21:49:35', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:20:29";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:50:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-02-27 21:50:29', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:22:32";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:52:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-02-27 21:52:33', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:22:46";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:52:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-02-27 21:52:46', '1', 'add', '156.210.43.215', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '6', '-1', '0', '4740.00', '1160', '5900', '', '0', '2024-02-27 21:52:46', '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', '', '1160', '1', ' خصم معالجة عجز  / ', '522', '-1160', '2024-02-27', '1', 'supplierPayedDeptController.php', '', '0','6', '0','1','1','1160','1');
UPDATE supplier SET  suppliercurrentDebt = '-1160', userid = '1', supplierdate = '2024-02-27'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '1160.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '522', supplierdebtchangeafter = '-1160.00', supplierdebtchangedate = '2024-02-27 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '6',currencyId='1',conversionFactor='1',payedInCurrency='1160',saveConversionFactor='1' WHERE supplierdebtchangeid = '897';
UPDATE save SET  savecurrentvalue = '5900',  userid = '1' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4740.00','1160', '0', '6', 'تسوية خزنة بالإضافة', '-1', '5900', '2024-02-27 21:52:46', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '26026' WHERE savedailyid = '26026';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1160', '1160', '2024-02-27', '1', '0', '0', '2024-02-27 21:52:46','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9560', '140', '1160', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1517932', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9560', '27', '1160', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-117170', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:22:47";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:52:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-02-27 21:52:47', '1', 'sucess', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:22:49";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:52:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-02-27 21:52:49', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:22:51";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 21:52:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 21:52:51', '1', 'addsellBill', '156.210.43.215', '', '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-02-27 18:37:21";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:07:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 22:07:21', '1', '', '156.210.43.215', '', '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-02-27 18:37:21";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:37:27";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:07:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:07:27', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:11";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:11', '1', 'add', '156.210.43.215', '', '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(1800,1,8,1593,30,'2024-02-27',1,0, '' ,0,0,0,0,0,'2024-02-27 22:08:12',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5802';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1593, 0, 0
                    , 390.00, -30, 0, 0, 1, '2024-02-27 22:08:12')
                ON DUPLICATE KEY UPDATE buyprice = 390.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-02-27*390.00," WHERE transferproductid = 8000;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '1', '30', '1', '8000', 'تحويل منتجات من المخزن', 'storemovementController.php', '60.00', '30', '1', '2024-02-27','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1593', '8', '30', '1', '2024-02-27');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 8, 1593, 0, 0
                    , 390.00, 30, 0, 0, 1, '2024-02-27 22:08:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '8', '30', '0', '8000', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2024-02-27','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', '1592', '32', '2024-02-27', '1', '0','1800',null,null,'2024-02-27 22:08:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '32', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5801';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1592, 0, 0
                    , 365.00, -32, 0, 0, 1, '2024-02-27 22:08:12')
                ON DUPLICATE KEY UPDATE buyprice = 365.00,
                        buyQuantity =buyQuantity+-32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2024-02-27*365.00," WHERE transferproductid = 8001;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1592', '1', '32', '1', '8001', 'تحويل منتجات من المخزن', 'storemovementController.php', '64.00', '32', '1', '2024-02-27','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1592', '8', '32', '1', '2024-02-27');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 8, 1592, 0, 0
                    , 365.00, 32, 0, 0, 1, '2024-02-27 22:08:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1592', '8', '32', '0', '8001', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '32', '1', '2024-02-27','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:12";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:12', '1', 'sucess', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:14";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:14', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:19";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:19', '1', '', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:56";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:56', '1', 'add', '156.210.43.215', '', '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(1801,1,7,1592,32,'2024-02-27',1,0, '' ,0,0,0,0,0,'2024-02-27 22:08:56',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5801';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1592, 0, 0
                    , 365.00, -32, 0, 0, 1, '2024-02-27 22:08:56')
                ON DUPLICATE KEY UPDATE buyprice = 365.00,
                        buyQuantity =buyQuantity+-32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:56' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "32*2024-02-27*365.00," WHERE transferproductid = 8002;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1592', '1', '32', '1', '8002', 'تحويل منتجات من المخزن', 'storemovementController.php', '32.00', '0', '1', '2024-02-27','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1592', '7', '32', '1', '2024-02-27');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 7, 1592, 0, 0
                    , 365.00, 32, 0, 0, 1, '2024-02-27 22:08:56')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+32, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:56' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1592', '7', '32', '0', '8002', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '32', '1', '2024-02-27','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', '1593', '30', '2024-02-27', '1', '0','1801',null,null,'2024-02-27 22:08:56',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-02-27' WHERE storedetailid = '5802';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 1, 1593, 0, 0
                    , 390.00, -30, 0, 0, 1, '2024-02-27 22:08:56')
                ON DUPLICATE KEY UPDATE buyprice = 390.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:56' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-02-27*390.00," WHERE transferproductid = 8003;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '1', '30', '1', '8003', 'تحويل منتجات من المخزن', 'storemovementController.php', '30.00', '0', '1', '2024-02-27','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1593', '7', '30', '1', '2024-02-27');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-27', 7, 1593, 0, 0
                    , 390.00, 30, 0, 0, 1, '2024-02-27 22:08:56')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-02-27 22:08:56' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '7', '30', '0', '8003', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2024-02-27','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:57";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:57', '1', 'sucess', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:38:59";
UPDATE user SET loginip = "156.210.43.215", lastactivetime = "2024-02-27 22:08:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-02-27 22:08:59', '1', 'show', '156.210.43.215', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:55:05";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:55:07";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 18:55:09";
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-02-27 18:55:39";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:25:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-02-27 22:25:39', '7', '', '197.192.233.22', '', '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-02-27 18:55:39";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:04:51";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:34:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:34:52', '7', 'addsellBill', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:05:18";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:35:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:35:19', '7', 'addAndRetuen', '197.192.233.22', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 065de476c6e53c
-- ----------------------------------------------------------------------------------------------------

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-02-27 22:34:52', '065de476c6e53c', '1', '0.00', '0', '0', '1', '185', '185', '185', '0', '5', '2024-02-27 22:35:19', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','185','0','','0','0','185','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','15537', '0', '2024-02-27 22:35:19', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '185', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 680;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('145','00304', '15537', '1', '304', '1', '185', '185', '0', '', '1', '2024-02-27 22:35:19', '304', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','680-1,');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
                where sellbilldetailid = 46100;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (304, '2024-02-27', 185, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-02-27', 185, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '7', storedetaildate = '2024-02-27 22:35:19' WHERE storedetailid = '891';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('304', '5', '1', '1', '15537', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1.00', '0', '7', '2024-02-27 22:35:19','0','0');
UPDATE save SET  savecurrentvalue = '5250',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5065.00','185', '0', '5', 'اضافة فاتورة مبيعات', '15537', '5250', '2024-02-27 22:35:19', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-02-27', 185, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-02-27', 185, 145, 145
                    , 145, 145, 145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 185, 145, 145
                    , 145, 145, 145, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+185, netSellCostBuyPrice = netSellCostBuyPrice+145
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+145
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+145
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+145
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+145
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 065de476c6e53c and sellbillId = 15537 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:05:19";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:35:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:35:19', '7', 'addsellBill', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:05:41";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:35:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 22:35:41', '7', '', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:05:49";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:35:49", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:35:49', '7', 'addsellBill', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:06:27";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:36:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:36:27', '7', 'addAndRetuen', '197.192.233.22', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 065de47a5c4e85
-- ----------------------------------------------------------------------------------------------------

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-02-27 22:35:49', '065de47a5c4e85', '1', '0.00', '0', '15', '1', '460', '445', '445', '0', '5', '2024-02-27 22:36:27', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','445','0','','0','0','445','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','اضافة فاتورة مبيعات','15538', '0', '2024-02-27 22:36:27', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '445', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16679;
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 ('390','01512', '15538', '1', '1512', '1', '460.00', '460', '0', '', '1', '2024-02-27 22:36:27', '1512', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','16679-1,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 46101;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1512, '2024-02-27', 445, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-02-27', 445, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-02-27 22:36:27' WHERE storedetailid = '5530';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1512', '5', '1', '1', '15538', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '7', '2024-02-27 22:36:27','0','0');
UPDATE save SET  savecurrentvalue = '5695',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5250.00','445', '0', '5', 'اضافة فاتورة مبيعات', '15538', '5695', '2024-02-27 22:36:27', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-02-27', 445, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-02-27', 445, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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, 445, 390, 390
                    , 390, 390, 390, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+445, netSellCostBuyPrice = netSellCostBuyPrice+390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+390
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+390
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 065de47a5c4e85 and sellbillId = 15538 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:06:28";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:36:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-02-27 22:36:28', '7', 'addsellBill', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:06:45";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:36:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 22:36:45', '7', '', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:06:52";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:36:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:36:52', '7', '', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:07:06";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:37:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:37:06', '7', 'add', '197.192.233.22', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'عماد', '', '100', '2024-02-27', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5595',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5695.00','100', '1', '5', 'إضافة مصروف', '4633', '5595', '2024-02-27 22:37:07', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2024-02-27', '7', '0', '0', '2024-02-27 22:37:07','اضافة اسم مصروف( عماد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9561', '145', '100', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '487870', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9561', '139', '100', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-2525128', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'عماد', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-02-27', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '9561', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4633';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:07:07";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:37:07", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:37:07', '7', 'sucess', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:07:09";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:37:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:37:09', '7', 'show', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:07:11";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:37:11", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:37:11', '7', '', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:08:19";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:38:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:38:19', '7', 'add', '197.192.233.22', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'علبه دبابيس ولزق ماليكان', '', '90', '2024-02-27', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5505',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5595.00','90', '1', '5', 'إضافة مصروف', '4634', '5505', '2024-02-27 22:38:19', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '90', '90', '2024-02-27', '7', '0', '0', '2024-02-27 22:38:19','اضافة اسم مصروف( علبه دبابيس ولزق ماليكان )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9562', '160', '90', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-3191873', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('9562', '139', '90', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-2525218', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'علبه دبابيس ولزق ماليكان', expensesdetails = '', expensesValue = '90.00', expensesdate = '2024-02-27', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '9562', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4634';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:08:21";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:38:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:38:21', '7', 'sucess', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:08:23";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:38:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-02-27 22:38:24', '7', 'show', '197.192.233.22', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-02-27 19:08:24";
UPDATE user SET loginip = "197.192.233.22", lastactivetime = "2024-02-27 22:38:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-02-27 22:38:24', '7', '', '197.192.233.22', '', 'DESKTOP');
